SQLite System Queries for Retrieving Database Object Information

SQLite databases contain a table named sqlite_master. This table stores all table, view, index, and trigger information for the database. The name column in the table has the name of the object, and the sql column contains the DDL used to create the object. The type column describes the type of object such as a table, view, index, or trigger. The examples below show queries for getting information about tables, views, indexes, and triggers contained in an SQLite database.

Tables

The tables in an SQLite database can be retrieved using the following query. The sql column contains the create table DDL statement.

select * from sqlite_master where type = 'table' order by name;

Views

The views in an SQLite database can be retrieved using the following query. The sql column contains the create view DDL statement.

select * from sqlite_master where type = 'view' order by name;

Indexes

The indexes defined in an SQLite database can be retrieved using the following query. The sql column contains the create index DDL statement.

select * from sqlite_master where type = 'index' order by name;

Triggers

The triggers defined in an SQLite database can be retrieved using the following query. The sql column contains the create trigger DDL statement.

select * from sqlite_master where type = 'trigger' order by name;

Listed below are links to articles containing system queries for other databases:

Cassandra: Cassandra System Queries

Firebird: Firebird System Queries

Microsoft SQL Server: SQL Server System Queries

MySQL: MySQL System Queries

Oracle: Oracle System Queries

PostgreSQL: PostgreSQL System Queries

Sybase: Sybase System Queries