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

Reply via email to