Randall Randall <[EMAIL PROTECTED]> writes:

> sqlite> create table package (rowid integer primary key autoincrement, name
> text);
> SQL error: near "autoincrement": syntax error
>
> What am I doing wrong, here?

You're putting in the word "autoincrement".  Also, "rowid" is a special word
in SQLite and should not generally be used as a column name.

In SQLite, integer primary keys will autoincrement if you insert a NULL value
into that field, either explicitly or implicitly (by inserting nothing into
that column):

sqlite> CREATE TABLE package
sqlite> (
sqlite>   id    INTEGER PRIMARY KEY,
sqlite>   name  TEXT
sqlite> );

sqlite> INSERT INTO package (id, name) VALUES (NULL, 'first row');
sqlite> INSERT INTO package (name) VALUES ('second row');

sqlite> .mode line
sqlite> SELECT * from package;

   id = 1
 name = first row

   id = 2
 name = second row

Reply via email to