Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does the database identity column refer to

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail what the database logo refers to. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Identification columns in the database: identity columns, also known as self-increment columns, can provide default values by the system without manually inserting values. There can be at most one identity column in a table, and null values are not allowed. In addition, the type can only be numeric.

Identify the meaning of the column:

When designing a data table, an identity column is added to the table ID to make the table grow according to the incremental rule, so the identity column is also called a self-increasing column. It means that you don't have to insert values manually, and the system provides default sequence values.

Characteristics of the identity column:

(1) the identity column does not have to be matched with the primary key, but a key is required.

(2) A table has at most one identification column.

(3) the type of identification column can only be numeric.

(4) when carrying out the entry and exit operation, the value of the column is generated by the system according to the law, and null values are not allowed.

Example: set the identity column when creating a 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 On the database identity column refers to what is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report