Search code examples
sqldatabasesqlitesyntax-erroridentifier

SQ Lite insert just a single identifier


I have the following table in my database

" CREATE TABLE Q_GROUP ( Id INTEGER PRIMARY KEY ); "

This is only needed to ensure different Items are in the same group. Each time, when adding new items, I need to create a unique group. The items are then connected to this group. The usual syntax for adding items and auto-incrementing the identifier is to specify the items but not the identifier. In this case, sq lite gives a syntax error when attempting this.

Should I add a foo value to the table, or is there a better way to do this in SQ Lite?

-- edit --

The following queries give a syntax error:

INSERT INTO Q_GROUP VALUES;
INSERT INTO Q_GROUP VALUES ();
INSERT INTO Q_GROUP () VALUES ();
INSERT INTO Q_GROUP ;

Solution

  • Use null as placeholder

    insert into Q_GROUP (Id) 
    values (null);
    

    SQLFiddle demo