Home > Database > Mysql Tutorial > body text

What are the characteristics of mysql identity columns?

王林
Release: 2023-05-26 23:55:04
forward
4173 people have browsed it

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

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!

Related labels:
source:yisu.com
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!