Reputation: 1075
I was hoping to be able to do something like
INSERT INTO `table`;
or maybe even a SET clause like
SET `primary_key` = null
where all the columns of the table aren't set (and are left to their default), with the exception of the autonumbered primary key which should be set.
Any suggestions?
Upvotes: 31
Views: 44090
Reputation: 24301
I believe that the more correct answer would be this:
INSERT INTO my_table DEFAULT VALUES
As suggested here: https://stackoverflow.com/a/13605273/148072
Upvotes: 39
Reputation: 1309
A little late.. But maybe handy for anyone looking for this answer.
INSERT INTO `table` () VALUES ()
You do not need any specification of the primary key.
Upvotes: 6
Reputation: 9148
Depends on your table. If it allows null values on every field, just do an insert with all values as null. If it does not allow null values for every field, you will need to insert a row with those fields having some value.
Upvotes: 3