![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
In a MySQL schema, what is the meaning of “AUTO_INCREMENT=3”\n
In MySQL, AUTO_INCREMENT=3 tells that the inserted record will start from 3 not the default 1. Let us first create a sample table and set auto increment to 3:
mysql> create table Auto_incrementDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20) -> )AUTO_INCREMENT=3; Query OK, 0 rows affected (0.52 sec)
Following is the query to insert some records in the table using insert command:
mysql> INSERT INTO Auto_incrementDemo(Name) values('John'); Query OK, 1 row affected (0.12 sec) mysql> INSERT INTO Auto_incrementDemo(Name) values('Larry'); Query OK, 1 row affected (0.15 sec) mysql> INSERT INTO Auto_incrementDemo(Name) values('Bob'); Query OK, 1 row affected (0.15 sec)
Following is the query to display records from the table using select command:
mysql> select *from Auto_incrementDemo;
This will produce the following output
+----+-------+ | Id | Name | +----+-------+ | 3 | John | | 4 | Larry | | 5 | Bob | +----+-------+ 3 rows in set (0.00 sec)
Look at the above sample output, id begins from 3, not 1, since we set AUTO_INCREMENT TO 3.
Advertisements