ROWIDs and the INTEGER PRIMARY KEY
Every row of every SQLite table has a 64-bit signed integer key that uniquely identifies the row within its table. This integer is usuallycalled the "rowid". The rowid value can be accessed using one of the specialcase-independent names "rowid","oid",or "_rowid_" in place of a column name.If a table contains a user defined column named "rowid","oid" or "_rowid_",then that name always refers the explicitly declared column and cannot be usedto retrieve the integer rowid value.
The data for each table in SQLite is stored as a B-Tree structure containingan entry for each table row,using the rowid value as the key. This means thatretrieving or sorting records by rowid is fast. Searching for a record with aspecific rowid,or for all records with rowids within a specified range isaround twice as fast as a similar search made by specifying any other PRIMARYKEY or indexed value.
With one exception,if a 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. Such acolumn is usually referred to as an "integer primary key". A PRIMARY KEY columnonly 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 ordinarytable column with integer affinity and a unique index,not as an alias for the rowid.
红色部分:如果主键为INTEGER,则the column是rowid的alias ;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。