mysql:[Err] 1068 - Multiple primary key defined


添加主鍵時,出現錯誤:[Err] 1068 - Multiple primary key defined

#增加主鍵
alter table my_test add phone_number VARCHAR(30) not null;
update my_test set phone_number=123456789;
alter table my_test add primary key (phone_number); #[Err] 1068 - Multiple primary key defined

這是因為已經存在主鍵 (id) 了,需要先刪除原來的主鍵,再設置新的主鍵

顯示主鍵:

show keys from table_name; #顯示主鍵


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM