
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Set MySQL int column to auto increment by 1 beginning at 10000?
Let us first create a table. Here, we have set UserId as AUTO_INCREMENT PRIMARY KEY −
mysql> create table DemoTable ( UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY ); Query OK, 0 rows affected (0.72 sec)
Following is the query to set int column to auto increment by 1 beginning at 10000 −
mysql> alter table DemoTable AUTO_INCREMENT=10000; Query OK, 0 rows affected (0.31 sec) Records: 0 Duplicates: 0 Warnings: 0
Insert records in the table using insert command −
mysql> insert into DemoTable values(); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.08 sec)
Display records from the table using select command −
mysql> select *from DemoTable;
This will produce the following output −
+--------+ | UserId | +--------+ | 10000 | | 10001 | | 10002 | | 10003 | +--------+ 4 rows in set (0.00 sec)
Advertisements