Inserting into SQL without specifying primary column

If Primary key is set to Auto-increment, there are chances that you would not want to provide its value in insert query.

 

Here is how to do it in MySQL:
INSERT INTO table_name VALUES (NULL, 'column b', 'col c');

Assumption^: The first column is the primary key set to AI

Similarly you can skip columns for other non-required data:
INSERT INTO table_name(col b,col c) VALUES ('column b', 'col c');


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *