Is there an SQLite equivalent to MySQL's DESCRIBE table?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
SQLite does not implement MySQL's DESCRIBE table_name syntax directly. Instead, SQLite exposes schema details through PRAGMA commands, shell helpers such as .schema, and catalog tables like sqlite_master, which together cover the same use cases with slightly different tools.
The Closest Replacement: PRAGMA table_info
If what you want from DESCRIBE is a quick list of columns and their metadata, the direct SQLite equivalent is usually:
This returns one row per column with fields such as:
- '
cidfor the column index' - '
namefor the column name' - '
typefor the declared type' - '
notnullindicating whetherNOT NULLwas declared' - '
dflt_valuefor the default value' - '
pkshowing primary-key position'
That covers the most common “tell me about this table” workflow.
Example
Typical results would tell you that id is part of the primary key, email is non-nullable, and created_at has a default value.
Compared with MySQL DESCRIBE, the information is similar in purpose even if the exact formatting differs.
When table_info Is Not Enough
PRAGMA table_info is intentionally compact. It does not show:
- indexes
- triggers
- foreign-key clauses in full text
- the complete original
CREATE TABLESQL
So if you need the whole schema definition rather than a column summary, use other SQLite introspection tools.
Seeing the Full Table Definition
In the sqlite3 shell, the most convenient command is:
That prints the CREATE TABLE statement and often related objects such as indexes:
This is often closer to what developers actually want when they say “describe the table,” because it shows the exact SQL structure rather than a reduced metadata view.
Querying sqlite_master
SQLite also stores schema definitions in a system catalog table called sqlite_master.
This is useful when you want to inspect not just the table, but also indexes, views, and triggers associated with it.
sqlite_master is especially handy in application code because it is queryable like ordinary SQL rather than being tied to the interactive shell.
PRAGMA table_xinfo for More Complete Column Metadata
For newer SQLite features such as hidden or generated columns, table_info can be incomplete. In that case, use:
This behaves like a fuller version of table_info. If you are working with virtual tables or generated columns and something seems to be missing, table_xinfo is often the missing piece.
Introspecting Indexes and Foreign Keys
A MySQL user coming from DESCRIBE often also wants related structural details. SQLite splits these into separate pragmas.
Indexes:
Foreign keys:
That modular approach is very SQLite-like. Instead of one catch-all convenience statement, you use small focused introspection commands depending on what you need.
Choosing the Right Tool
A practical rule of thumb is:
- use
PRAGMA table_infofor column summaries - use
PRAGMA table_xinfowhen advanced column metadata matters - use
.schemain the shell for full object definitions - use
sqlite_masterin SQL when you want raw schema records - use
PRAGMA index_listandPRAGMA foreign_key_listfor related structural details
Once you know that toolkit, the lack of DESCRIBE stops being a problem.
Common Pitfalls
- Running
DESCRIBE users;directly in SQLite and expecting MySQL syntax to work. - Assuming
PRAGMA table_infocontains every detail about indexes, triggers, and foreign keys. - Forgetting that
.schemais a shell command, not standard SQL you can run through every database driver. - Looking only at
table_infowhen hidden or generated columns requiretable_xinfoinstead. - Treating SQLite schema inspection like a single-command workflow when it is really a small set of focused inspection tools.
Summary
- SQLite has no direct
DESCRIBEstatement, butPRAGMA table_info(table_name)is the closest equivalent. - Use
.schemawhen you want the fullCREATE TABLEstatement in the SQLite shell. - Query
sqlite_masterwhen you want raw schema records from SQL. - Use
table_xinfofor richer column metadata in advanced cases. - Think of SQLite schema inspection as a toolkit of
PRAGMAcommands rather than one MySQL-style convenience statement.

