Pixelherz
Pixelherz

Reputation: 21

Inserting a row in table that consist of only one auto increment PK column

I have this table:

CREATE TABLE `VormerkListe` (
  `vormerkListeID` int NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`vormerkListeID`)
)

And I try to add a new column with this, found here:

INSERT INTO VormerkListe DEFAULT VALUES;

But I get this error:

INSERT INTO VormerkListe DEFAULT VALUES Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT VALUES' at line 1  0.031 sec

Upvotes: 0

Views: 73

Answers (2)

Bill Karwin
Bill Karwin

Reputation: 562260

You can also do this:

INSERT INTO VormerkListe () VALUES();

This looks funny, but I use it regularly. It means to use the default for every column in the table.

Upvotes: 0

asd-tm
asd-tm

Reputation: 5263

You can insert a null value in the auto column. Something like this:

INSERT INTO VormerkListe (vormerkListeID) VALUES(null);

Upvotes: 1

Related Questions