SQLite3 Show Table Information

When working with an SQLite3 database I occasionally forget a column name that I need to know. This tends to be followed by being unable to remember how to find out column names (and other information) for a table. Future me, here's how to do it.

If you know the table name, great. If not, you can ask SQLite3 to list all tables with the following command:
.tables

Once you know the table name, you can find the table information with the following:
PRAGMA table_info(table-name);

Each column in the table is printed out on a new row as follows:
cid|name|type|notnull|dflt_value|pk

A real world example:
3|date_retrieved|TIMESTAP|0||0

More information on this can be found here: http://www.sqlite.org/pragma.html#pragma_table_info
This was posted on Tue 24 Jun 2014 (5 years ago) by Ryan McConville