contentintech
Databases

SQLite

Use the CLI, query data and manage small transactional databases.

Updated Official documentation ↗

CLI

sqlite3 app.dbOpen or create a database
.tablesList tables inside the SQLite shell
.schema usersInspect a table definition
.headers onDisplay result-column headings

Query

SELECT id, name FROM users LIMIT 10;Read a bounded result
SELECT name, COUNT(*) FROM users GROUP BY name;Aggregate by a field
PRAGMA table_info(users);Inspect column metadata
EXPLAIN QUERY PLAN SELECT * FROM users WHERE id = 1;Inspect query strategy

Integrity and backup

PRAGMA foreign_keys = ON;Enable FK enforcement for the connection
BEGIN;Start an explicit transaction
ROLLBACK;Undo the current transaction
.backup backup.dbCreate a consistent backup through the shell

Section navigation