MySQL Add primary key
MySQL Add primary key
Add primary key to MySQL table using alter table syntax and primary key keyword.
MySQL Add primary key syntax
ALTER TABLE table_name ADD PRIMARY KEY (column_name);
Add primary key example
ALTER TABLE `books` ADD PRIMARY KEY (id);
Output
table `books` altered.