문제

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