SQLite PRAGMA

PRAGMA table_info

This pragma returns one row for each normal column in the named table.

PRAGMA schema.table_info(table-name);

On the sample database

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

cidnametypenotnulldflt_valuepk
0idINTEGER0NULL1
1album_idINTEGER1NULL0
2nameTEXT1NULL0
3msINTEGER0NULL0
4bytesINTEGER0NULL0
5priceREAL0NULL0

What the SQLite documentation says

This pragma returns one row for each normal column in the named table. Columns in the result set include: "name" (its name); "type" (data type if given, else ''); "notnull" (whether or not the column can be NULL); "dflt_value" (the default value for the column); and "pk" (either zero for columns that are not part of the primary key, or the 1-based index of the column within the primary key).

The "cid" column should not be taken to mean more than "rank within the current result set".

The table named in the table_info pragma can also be a view.

This pragma does not show information about generated columns or hidden columns. Use PRAGMA table_xinfo to get a more complete list of columns that includes generated and hidden columns.

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

← synchronous · table_list →