SQLite SELECT default order with PRIMARY KEY ASC

前端 未结 2 1698
日久生厌
日久生厌 2021-01-13 05:57

I\'ve created a SQLite table using:

CREATE TABLE T1 (
  CN INTEGER PRIMARY KEY ASC,
  Name TEXT
);

If I do:

SELECT * FROM T         


        
2条回答
  •  生来不讨喜
    2021-01-13 06:46

    The second question might be useful to others.

    From the SQLite documentation:

    Except for WITHOUT ROWID tables, all rows within SQLite tables have a 64-bit signed integer key that uniquely identifies the row within its table. This integer is usually called the "rowid".
    ... 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.

    This also holds for columns that are declared of type "INTEGER PRIMARY KEY ASC", so in your table CN is an alias for "rowid"

    Further information can be found here: http://www.sqlite.org/lang_createtable.html#rowid

提交回复
热议问题