Supply a NULL for the INTEGER PRIMARY KEY to tell SQLite to "figure it out for yourself" (c) Siddharta Gautama "Buddha"
-----Ursprüngliche Nachricht----- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Scott Robertson Gesendet: Donnerstag, 28. Juni 2018 13:48 An: sqlite-users@mailinglists.sqlite.org Betreff: [EXTERNAL] [sqlite] Shouldn't have to specify primary key explicitly SQLite is supposed to autoincrement by default when a column is defined as "INTEGER PRIMARY KEY" according to everything I've read. But I've only gotten this to work if I let SQLite create its own PK column. If I have an explicit PK column, I am expected to specify an ID myself. What am I missing? I don't know why I'm getting this error. Thanks. CREATE TABLE test1 (name TEXT, date DATE); INSERT INTO test1 VALUES ('Barney', 1999 ); SELECT * FROM test1; name date ---------- ---------- Barney 1999 SELECT *, rowid FROM test1; name date rowid ---------- ---------- ---------- Barney 1999 1 CREATE TABLE test2 ( id INTEGER PRIMARY KEY, book text, page INTEGER ); INSERT INTO test2 VALUES ( 'Fletch', 245 ); Error: table test2 has 3 columns but 2 values were supplied INSERT INTO test2 VALUES ( 1, 'Dragnet', 17 ); SELECT *, rowid FROM test2; id book page id ---------- ---------- ---------- ---------- 1 Dragnet 17 1 INSERT INTO test2 VALUES ( 'Lord of the Rings', 327 ); Error: table test2 has 3 columns but 2 values were supplied INSERT INTO test2 VALUES ( 9, 'Lord of the Rings', 327 ); SELECT *, rowid FROM test2; id book page id ---------- ---------- ---------- ---------- 1 Dragnet 17 1 9 Lord of th 327 9 -- _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___________________________________________ Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0 May be privileged. May be confidential. Please delete if not the addressee. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users