
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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)
- Related Articles
- MySQL query to set my auto increment column ( id ) to zero or reset the value of auto increment field?
- How to change auto increment number in the beginning in MySQL?
- Set custom Auto Increment with ZEROFILL in MySQL
- How can I set my auto-increment value to begin from 1 in MySQL?
- How to set initial value and auto increment in MySQL?
- How to handle fragmentation of auto increment ID column in MySQL?
- How to add auto-increment to column in MySQL database using PhpMyAdmin?
- Increment column value ‘ADD’ with MySQL SET clause
- How to create a table with auto-increment column in MySQL using JDBC?
- Set auto increment initial value for MySQL table using ALTER command
- What if I forgot to set Auto Increment? Can I set it later in MySQL?
- Passing NULL to MySQL for auto increment?
- Set the MySQL primary keys auto increment to be unlimited (or incredibly huge)?
- Truncate a MySQL table and then set a custom value to auto increment
- How to set auto-increment to an existing column in a table using JDBC API?

Advertisements