Home >Database >Mysql Tutorial >What are the characteristics of mysql identity columns?

What are the characteristics of mysql identity columns?

王林
王林forward
2023-05-26 23:55:044330browse

1. The identification column does not have to be matched with the primary key, but it is required to be a key.

2. A table has at most one identity column.

3. The type of the identification column can only be numeric.

By SET auto_increment_increment=3, the identity column can set the step size.

4. The starting value can be set by manual insertion.

Example

DROP TABLE IF EXISTS tab_id;
 
CREATE TABLE tab_id(
id INT PRIMARY KEY AUTO_INCREMENT,
NAME VARCHAR(20)
);
 
INSERT INTO tab_id VALUES(NULL,'john');#可重复执行插入
INSERT INTO tab_id(NAME) VALUES('lucy');
SELECT * FROM tab_id;
 
#自增步长
SET auto_increment_increment=3;

The above is the detailed content of What are the characteristics of mysql identity columns?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete