PRAGMA index_xinfo
This pragma returns information about every column in an index.
PRAGMA schema.index_xinfo(index-name);
On the sample database
What PRAGMA index_xinfo(tracks_album) returns on the sample database, in SQLite 3.54.1 as built for the browser by sql.js:
| seqno | cid | name | desc | coll | key |
|---|---|---|---|---|---|
| 0 | 1 | album_id | 0 | BINARY | 1 |
| 1 | -1 | NULL | 0 | BINARY | 0 |
What the SQLite documentation says
This pragma returns information about every column in an index. Unlike this index_info pragma, this pragma returns information about every column in the index, not just the key columns. (A key column is a column that is actually named in the CREATE INDEX index statement or UNIQUE constraint or PRIMARY KEY constraint that created the index. Auxiliary columns are additional columns needed to locate the table entry that corresponds to each index entry.)
Output columns from the index_xinfo pragma are as follows:
- The rank of the column within the index. (0 means left-most. Key columns come before auxiliary columns.)
- The rank of the column within the table being indexed, or -1 if the index-column is the rowid of the table being indexed and -2 if the index is on an expression.
- The name of the column being indexed, or NULL if the index-column is the rowid of the table being indexed or an expression.
- 1 if the index-column is sorted in reverse (DESC) order by the index and 0 otherwise.
- The name for the collating sequence used to compare values in the index-column.
- 1 if the index-column is a key column and 0 if the index-column is an auxiliary column.
If there is no index named index-name but there is a WITHOUT ROWID table with that name, then (as of SQLite version 3.30.0 on 2019-10-04) this pragma returns the columns of the WITHOUT ROWID table as they are used in the records of the underlying b-tree, which is to say with de-duplicated PRIMARY KEY columns first followed by data columns.
From sqlite.org's pragma documentation for SQLite 3.54.1, in the public domain.
← index_list · integrity_check →