mysql create a primary key, modify the primary key



// Add a pid field and the primary key (AUTO_INCREMENT) increment (auto_increment), is not null, int unsigned type
alter table table1 add pid int unsigned not null auto_increment primary key;


// a primary key may be modified to 0
update table1 set pid=0 where pid=6;

 

Suppose the primary key id, field id data can be guaranteed to be unique, but only a primary key of a table.
Primary key values: 0 modified, may be present, it is a row order.
Newly added 0, there is not allowed to change according to the row number.
Inherent in 0, allowed to exist, beginning from 1 incremental changes.
Insert into data id = 0, data is increased from the actual number of rows

insert table1 (transactor,name_new,pid) values("xiaohong","hahha",0);

 

 

reference:

https://www.cnblogs.com/sun-yanglu/p/9581701.html
https://www.jianshu.com/p/e9338da60a61

 

Guess you like

Origin www.cnblogs.com/sea-stream/p/11300539.html