In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail the usage of the identification column in mysql. 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.
What is the identity column?
Identity columns are also known as self-growing columns.
Meaning: you don't have to insert values manually, the system provides default sequence values.
Features:
1. Must the identity column be matched with the primary key? Not necessarily, but the requirement is a key
2. How many identity columns can a table have? One at most!
3. The type of identity column can only be numeric.
4. The step size of the identity column can be set through SET auto_increment_increment=3;.
Set the identity column AUTO_INCREMENT 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%'
Generating columns (including identity columns) is an important feature of DB2, which is used to automatically generate column values. The value of a generated column is not derived from an INSERT or UPDATE operation, but is automatically generated by DB2 based on a predefined definition. In the application, users can choose different generation columns according to different requirements to simplify the development or improvement of the application.
The generated column (GENERATED COLUMNS) of DB2 is created by GENERATED ALWAYS AS in the CREATE TABLE or ALTER TABLE statement. Clause is created.
The value of the generated column of DB2 is generated by a user-defined expression, and DB2 calculates the column value of the generated column based on the expression. When the application customizes the generation of columns, you need to specify the GENERATED AS EXPRESSION statement in the CREATE TABLE or ALTER TABLE statement.
This is the end of the usage of the identification column in mysql. I hope the above content can be helpful to you and 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.