Can we skip a column name while inserting values in MySQL?

MySQLMySQLi Database

Yes, we can do that. Let us first create a table −

mysql> create table DemoTable
   -> (
   -> StudentName varchar(100),
   -> StudentAge int
   -> );
Query OK, 0 rows affected (0.72 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable(StudentAge) values(23);
Query OK, 1 row affected (0.22 sec)

mysql> insert into DemoTable(StudentName) values('John');
Query OK, 1 row affected (0.21 sec)

Display all records from the table using select statement −

mysql> select *from DemoTable;

This will produce the following output. NULL will get inserted for the skipped column values −

+-------------+------------+
| StudentName | StudentAge |
+-------------+------------+
| NULL        |         23 |
| John        |       NULL |
+-------------+------------+
2 rows in set (0.00 sec)
raja
Published on 10-Jul-2019 11:59:17
Advertisements