In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Mysql creates a table with self-increasing columns
Create table inc (id int (10) not null auto_increment,name varchar (20), primary key (id))
Note:
Auto-increment column must be key
There are no quotation marks in the front id, and there can be no quotation marks when the back is set to key
2. Use self-incrementing column
Mysql > insert into inc values (id,'leo')
Query OK, 1 row affected (0.00 sec)
Mysql > select * from inc
+-+ +
| | id | name |
+-+ +
| | 1 | leo |
+-+ +
1 row in set (0.00 sec)
Mysql > insert into inc values (id,'dem')
Query OK, 1 row affected (0.00 sec)
Mysql > select * from inc
+-+ +
| | id | name |
+-+ +
| | 1 | leo |
| | 2 | dem |
+-+ +
2 rows in set (0.00 sec)
You can see that the self-increment column starts from 1 by default.
3. Set self-increment column
If you do not want the increment column to start at 1, you can use the following statement to modify the starting value of the increment
Alter table inc auto_increment=100
Mysql > insert into inc values (id,'jack')
Query OK, 1 row affected (0.01sec)
Mysql > select * from inc
+-+ +
| | id | name |
+-+ +
| | 1 | leo |
| | 2 | dem |
| | 100 | jack |
+-+ +
3 rows in set (0.00 sec)
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.