質問

Usually, when Sqlite encounters an integer primary key statement, e.g.

CREATE TABLE [T] (id INTEGER PRIMARY KEY, [...]);

then the id column will be an alias for the rowid column, which is Sqlite's internal ID column.

However, when appending not null to

CREATE TABLE [T] (Id INTEGER PRIMARY KEY NOT NULL, [...]);

is aliasing still activated?

NOT NULL should not affect the semantic properties of the table, but the rules for aliasing are quite strict (e.g. it won't accept int instead of integer), so maybe this slight change will already prevent aliasing.

役に立ちましたか?

解決

According to the documentation,

if a rowid table has a primary key that consists of a single column and the declared type of that column is "INTEGER" in any mixture of upper and lower case, then the column becomes an alias for the rowid.

"NOT NULL" is not part of the type but is a (superfluous) column constraint, so this will still be the rowid.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top