SQLite PRAGMA

PRAGMA index_info

This pragma returns one row for each key column in the named index.

PRAGMA schema.index_info(index-name);

On the sample database

What PRAGMA index_info(tracks_album) returns on the sample database, in SQLite 3.54.1 as built for the browser by sql.js:

seqnocidname
01album_id

What the SQLite documentation says

This pragma returns one row for each key column in the named index. 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. Index entries also usually contain auxiliary columns that point back to the table row being indexed. The auxiliary index-columns are not shown by the index_info pragma, but they are listed by the index_xinfo pragma.

Output columns from the index_info pragma are as follows:

  1. The rank of the column within the index. (0 means left-most.)
  2. The rank of the column within the table being indexed. A value of -1 means rowid and a value of -2 means that an expression is being used.
  3. The name of the column being indexed. This columns is NULL if the column is the rowid or an expression.

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 PRIMARY KEY columns of the WITHOUT ROWID table as they are used in the records of the underlying b-tree, which is to say with duplicate columns removed.

From sqlite.org's pragma documentation for SQLite 3.54.1, in the public domain.

← incremental_vacuum · index_list →