In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.