sql - MySQL: Does dropping primary key removes unique constraint and/or index? -


I have column 1 as the primary key, I believe that is why it has a unique barrier and index . Now I want to present column 2 as a new primary key, but I want to place Column 1 as a secondary key on it and with the index as a secondary key. The question is if I will execute

  my_table drop primary key to replace the table;  

Is this MySQL (InnoDB)?

Yes it will skip the current primary key in column 1 Try it as below

  drop table if existing test_index; The query is ok, affect the 0 rows (0.04 seconds) Test test_index (id INT, primary key (id)); Queries are OK, affected by 0 rows (0.25 seconds) Optional table test_index column email CHAR (50) No zero; Query OK, 0 rows affected (0.33 seconds) Records: 0 Duplicate: 0 Warning: 0 Add ALTER table test_index primary key, add unique key (id), add primary key (email); Query OK, 0 rows affected (0.48 seconds) Records: 0 Duplicate: 0 Warning: 0 Show table making test_index \ g ************************************************************ * ** 1. Row ************************************** Table: Create test_index table: Create table`` test_index` (`ID` int (11) NULL default '0', `email` four (50) not NULL, primary key (` email`), unique key `ID` (` ID`)) engine = InnoDB default CHARSET set = UTF8 1 line (0.00 seconds )  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -