0

This should be an easy one. I need the SQL to insert into a table that has only one column and it is and autoincrement field.

Similar to this post but SQLite (I am new to SQLite). Inserting rows into a table with one IDENTITY column only

    create table ConnectorIDs
    (
        ID   integer primary key AUTOINCREMENT
    );

    --none of the following work                
    INSERT INTO ConnectorIDs VALUES(DEFAULT);
    INSERT ConnectorIDs DEFAULT VALUES;

Yes this is strange and if you care here is the reason, if you want to tell me a better way. I have several different item tables that all can have many-to-many links between them but sparse. Instead of having n! bridge tables, or one bridge table with a "Type" that I can't guarantee truly maps to the correct table. I will have one ConnectorID table and each item with have a connectorID key. Then I can have one bridge table.

runfastman
  • 927
  • 2
  • 11
  • 31

1 Answers1

2

Insert a null value:

INSERT INTO ConnectorIDs VALUES(NULL);

From the docs:

If no ROWID is specified on the insert, or if the specified ROWID has a value of NULL, then an appropriate ROWID is created automatically.

laalto
  • 150,114
  • 66
  • 286
  • 303