Home > Database > Mysql Tutorial > body text

What does database identity column mean?

清浅
Release: 2020-09-08 10:58:12
Original
10777 people have browsed it

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.

What does database identity column mean?

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;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template