
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
Insertion in a MySQL Table with Auto Increment Column
Let us first create a table −
mysql> create table DemoTable -> ( -> StudentId int NOT NULL AUTO_INCREMENT, -> PRIMARY KEY(StudentId) -> ); Query OK, 0 rows affected (0.60 sec)
Insert some records in the table using insert command. Here, we have inserted a value, but since it is AUTO_INCREMENT, therefore, the default value would be visible −
mysql> insert into DemoTable(StudentId) values(0); Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output. The default AUTO_INCREMENT value 1 as the first value is visible −
+-----------+ | StudentId | +-----------+ | 1 | +-----------+ 1 row in set (0.00 sec)
Advertisements