The identity column in the database is also called an auto-increment column. It can provide a default value by the system without inserting the value manually. There can be at most one identity column in a table, and no null values are allowed. , and the type can only be numeric.
The meaning of the database identification column:
When designing the data table, an identification column will be added to the table ID so that The table grows according to the incremental rule, so the identity column is also called an auto-increment column. It means that you don’t need to insert values manually. The system provides default sequence values
Characteristics of identification columns:
(1) The identification column does not have to be the same as the primary key Match, but the requirement is a key
(2) A table can only have at most one identification column
(3) The type of the identification column can only be numeric type
(4) When performing entry and exit operations, the value of this column is uniformly generated by the system according to rules, and no null values are allowed
Example: Set the identity column when creating the table
DROP TABLE IF EXISTS tab_identity; CREATE TABLE tab_identity( id INT , NAME FLOAT UNIQUE AUTO_INCREMENT, seat INT ); TRUNCATE TABLE tab_identity; INSERT INTO tab_identity(id,NAME) VALUES(NULL,'john'); INSERT INTO tab_identity(NAME) VALUES('lucy'); SELECT * FROM tab_identity; SHOW VARIABLES LIKE '%auto_increment%'; SET auto_increment_increment=3;
The above is the detailed content of What does database identity column mean?. For more information, please follow other related articles on the PHP Chinese website!