Answers for "mysql set primary key"

SQL
4

mysql set primary key

ALTER TABLE tableName MODIFY COLUMN id INT; /* First you should drop auto increment */
ALTER TABLE tableName DROP PRIMARY KEY; /* Dop primary key */
ALTER TABLE tableName ADD PRIMARY KEY (new_id); /* Set primary key to the new column */
ALTER TABLE tableName MODIFY COLUMN new_id INT AUTO_INCREMENT; /* Set auto increment to the new primary key */
Posted by: Guest on March-04-2020
1

mysql drop key

ALTER TABLE tbl_quiz_attempt_master
  DROP INDEX `PRIMARY`;
Posted by: Guest on May-27-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language