//添加一個字段pid並且設置為主鍵(auto_increment)自增(auto_increment),不可為null,類型為int unsigned
alter table table1 add pid int unsigned not null auto_increment primary key;
//可以將一個主鍵修改為0
update table1 set pid=0 where pid=6;
假設id為主鍵,id可以保證字段數據唯一性,但是一張表只有一個主鍵。
主鍵的值:修改成的0,可以存在,就是排個序。
新添加的0,不允許存在,要根據行號改變。
本身存在的0,不允許存在,要從1開始遞增變化。
Insert 進去 id = 0的數據,數據會從實際的行數開始增加
insert table1 (transactor,name_new,pid) values("xiaohong","hahha",0);
參考:
https://www.cnblogs.com/sun-yanglu/p/9581701.html
https://www.jianshu.com/p/e9338da60a61