
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
Skip Column When Inserting into MySQL
If your first column is AUTO_INCREMENT, then you can skip the column and place the value NULL. Let us first create a table −
mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(100), StudentAge int ); Query OK, 0 rows affected (0.60 sec)
Insert some records in the table using insert command. Here, we have skipped the first column, since it is AUTO_INCREMENT −
mysql> insert into DemoTable values(NULL,'Robert',21); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(NULL,'Sam',22); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(NULL,'Bob',24); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(NULL,'Carol',20); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+------------------+------------+ | StudentId | StudentFirstName | StudentAge | +-----------+------------------+------------+ | 1 | Robert | 21 | | 2 | Sam | 22 | | 3 | Bob | 24 | | 4 | Carol | 20 | +-----------+------------------+------------+ 4 rows in set (0.00 sec)
Advertisements