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
精彩评论