In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the role of mysql sequence is what, has a certain reference value, need friends can refer to. I hope you all have a lot of success after reading this article. Let's take a look at it together.
MySQL sequence is a set of integers: 1, 2, 3, etc., because a data table can only have one field self-increasing primary key, if you want to achieve other fields also automatically increased, you can use MySQL sequence to achieve.
The easiest way to use sequences in MySQL is to define columns using MySQL AUTO_INCREMENT.
In the following example, a data table insect is created, and the id in the insect table can be automatically increased without specifying a value.
mysql> CREATE TABLE Insects> CREATE TABLE Insects - >(- > ( - > id INT UNSIGNED NOT NULL AUTO_INCREMENT,- > id INT UNSIGNED NOT NULL AUTO_INCREMENT , - > PRIMARY KEY(id),- > PRIMARY KEY (id ), - > name VARCHAR(30)NOT NULL,#type of insect- > name VARCHAR (30 )NOT NULL ,#type of insect - > Date NOT NULL,#date collection- > Date NOT NULL,#date collection - > origin VARCHAR (30) NOT NULL#where to collect- > origin VARCHAR (30) NOT NULL #where to collect);); query OK, 0 rows affected (0.02 s) query OK, 0 rows affected (0.02 s) mysql> INSERT INTO insect (id, name, date, origin) VALUES> INSERT INTO insect (id, name, date, origin) values - >(NULL,'Housefly,''2001-09- 10',' Kitchen'), - >(NULL,'Housefly,''2001-09- 10',' Kitchen'), - >(NULL,'millipede','2001-09- 10','lane'), - >(NULL,' millipede','2001-09- 10',' lane'), - >(NULL,'Grasshopper','2001-09- 10',' Front Yard ');- >(NULL,' Grasshopper ','2001-09- 10','Front Yard'); Query OK, 3 rows affected (0.02 seconds) Query OK, 3 rows affected (0.02 seconds) Records: 3 duplicates: 0 Warnings: 0 Records: 3 duplicates: 0 Warnings: 0 mysql> SELECT * FROM INSECTS ORDER BY id; SELECT * FROM INSECTS ORDER BY id ;+ -------------| id |name| date| source|| id |name | date | source |+ ---- + ------------- + ------------ + ------------ ++ ---- + ------------- + ------------ + ------------ +| 1 |housefly| 2001-09-10 |kitchen|| 1 |housefly | 2001 - 09 - 10 |kitchen | | 2 |millipedes| 2001-09-10 |Lane|| 2 |millipedes | 2001 - 09 - 10 |Lane | | 3 |Grasshopper| 2001-09-10 |front yard|| 3 |Grasshopper| 2001 - 09 - 10 |front yard| + -------------(0.00 seconds) 3 rows in the group (0.00 seconds) Thank you for reading this article carefully, I hope Xiaobian share what the role of mysql sequence is to help everyone, but also hope that everyone more support, pay attention to the industry information channel, encounter problems to find, detailed solutions waiting for you to learn!
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.