开发者

sqlite3: how to detect rowid alias column (primary key)

Using SQLite3, if you create a table like this:

CREATE TABLE MyTable (
id int primary key,
--define other columns here--
)

it turns out sqlite3_column_type(0) always returns SQLITE_NULL. If I read on a bit, this may well be by design because this column is actually an alias to the internal rowid field.

Still, what is the programatical way to determine a certain column is an/the alias to the rowid field?

(Perhaps related, can I use sqlite3_column_type(x)==SQLITE_NULL to determine if the field of the curr开发者_开发问答ent record holds NULL?)


According to http://www.sqlite.org/draft/lang_createtable.html#rowid

A PRIMARY KEY column only becomes an integer primary key if the declared type name is exactly "INTEGER". Other integer type names like "INT" or "BIGINT" or "SHORT INTEGER" or "UNSIGNED INTEGER" causes the primary key column to behave as an ordinary table column with integer affinity and a unique index, not as an alias for the rowid.

So in your case it's "int" so invalid alias

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜