AUTOINCREMENT and order of arguments in INTEGER PRIMARY KEY

Viewed 28

In SQLite, the following works:

CREATE TABLE "b" (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL);

but the following throws an error:

CREATE TABLE "c" (id INTEGER AUTOINCREMENT PRIMARY KEY NOT NULL);

the error being:

Execution finished with errors.
Result: near "AUTOINCREMENT": syntax error
At line 6:
CREATE TABLE "c" (id INTEGER AUTOINCREMENT

Why changing the order of the arguments throws a syntax error?

1 Answers

As specified in the docs, in SQLite AUTOINCREMENT must go after PRIMARY KEY.

Related