Pragmatic SQLite Administration
Table Info
Inspect Columns
SQLite exposes table metadata through pragma_table_info, including column order, type, nullability, and primary-key position.
Program
Play the script to choose a table and inspect its column metadata.
table_info_report.sql
CREATE TABLE products (id INTEGER PRIMARY KEY, sku TEXT NOT NULL, price INTEGER);
CREATE TABLE order_items (order_id INTEGER, product_id INTEGER, quantity INTEGER NOT NULL);
WITH params(table_name) AS (VALUES ()) SELECT name, type, "notnull" AS required, pk FROM pragma_table_info((SELECT table_name FROM params)) ORDER BY cid;
CREATE TABLE products (id INTEGER PRIMARY KEY, sku TEXT NOT NULL, price INTEGER);
CREATE TABLE order_items (order_id INTEGER, product_id INTEGER, quantity INTEGER NOT NULL);
WITH params(table_name) AS (VALUES ()) SELECT name, type, "notnull" AS required, pk FROM pragma_table_info((SELECT table_name FROM params)) ORDER BY cid;
pragma_table_info
`pragma_table_info` returns one row per column.
required flag
The `notnull` field shows which columns reject NULL values.
primary key
`pk` marks primary-key columns and their key order.