在MySQL中,設置主鍵的步驟如下:
示例:
CREATE TABLE example_table (
id INT PRIMARY KEY,
name VARCHAR(50)
);
示例:
ALTER TABLE example_table
ADD PRIMARY KEY (id);
示例:
ALTER TABLE example_table
DROP PRIMARY KEY,
ADD PRIMARY KEY (id);
示例:
CREATE TABLE example_table (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50)
);