开发者

Error in near 'Autoincrement'

I get a syntax error near AUTOINCREMENT. What is the cause of this error?

CREATE TABLE person (
    id INTEGER NOT NULL AUTOINCREME开发者_如何学CNT,
    name TEXT NOT NULL
);

CREATE TABLE department (
    id INTEGER NOT NULL AUTOINCREMENT,
    name TEXT NOT NULL,
    FOREIGN KEY (leader) REFERENCES person(id)
);


According to SQLite FAQ you have to declare either a INTEGER PRIMARY KEY or INTEGER PRIMARY KEY AUTOINCREMENT column to achieve that.


In SQLite you need not to specify AUTOINCREMENT if you are specifying a column as Primary Key...


SQLite AUTOINCREMENT : You Should Avoid Using It

Unless you create a table specifying the WITHOUT ROWID option, you get an implicit auto increment column called rowid.

The rowid column store 64-bit signed integer that uniquely identifies a row within the table.


It's an easy solution. Just use AUTOINCREMENT instead of AUTO_INCREMENT

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜