# Identity column / * is also known from the growth column Meaning: You can not manually insert the value, the system provides a default sequence value characteristics: 1. Expresses its columns and primary key must match it? Not necessarily, but it requires a Key 2. A table can have only one identity column! 3. Identify the type of column restrictions? Only numeric type (int, a float, Double) 4. identity column can set auto_increment_increment = 3; setting step, may be manually inserted by a value set starting value * / # a provided identity column when creating the table create table tab_identity ( id int Primary Key, name VARCHAR (20) ); Show the Tables; # insert data iNSERT INTO tab_identity values (1, "john"); iNSERT INTO tab_identity values (2, "Lily"); # here's id number you need to manually enter select * from tab_identity; if you want to automatically insert id columns, you need to drop the Table IF EXISTS tab_identity; the Create the Table tab_identity ( ID int Primary Key AUTO_INCREMENT, name VARCHAR (20 is) ); # insert data INSERT INTO tab_identity values (null, "John"); INSERT INTO tab_identity values (null, "Lily"); INSERT INTO tab_identity (name) values ( "Lucy ") # View auto_increment variable parameters show variables like"% auto_increment% " ; can be modified by modifying the amplitude of the updated variable step size actually auto_increment_increment parameters: step auto_increment_offset parameters: starting position # changing the step SET = auto_increment_increment. 3; Show variables like "% auto_increment%"; the data table is deleted # TRUNCATE table tab_identity; SELECT * from tab_identity; # reinsert data insert into tab_identity values (null, " john"); INTO tab_identity values INSERT (null, "Lily"); INSERT INTO tab_identity (name) values ( "lucy") ); Show the Variables like " AUTO_INCREMENT%% "; SET = auto_increment_increment. 1; ) At this time in the table is the order id 1,4,7 ,. . . . # Starting value is not supported by similar steps in the modification, how to modify it? # Delete the data in the table TRUNCATE Table tab_identity; SELECT * from tab_identity; # reinsert data INSERT INTO tab_identity values (10, "John"); INSERT INTO tab_identity values (null, "Lily"); INSERT INTO tab_identity (name) values ( "lucy"); at this time the table is the order id 10,13,16 ,. . . . The start value is modified to # two, provided an identity column (similar modifications constraint) is modified table # table is prepared drop Table IF EXISTS tab_identity; Create Table tab_identity ( ID int, name VARCHAR (20 is) desc tab_identity; # Set ID column ALTER Table tab_identity Modify column ID int Primary Key AUTO_INCREMENT; # insert data INSERT INTO tab_identity values (null, "John"); INSERT INTO tab_identity values (null, "Lily"); INSERT INTO tab_identity (name ) values ( "lucy"); # Third, delete the identity column when you modify the table the ALTER tab_identity the modify the table column the above mentioned id int; Show index from tab_identity;