All tags
sqlite
Narrow down
Other tips30
- Tip
PRAGMA table_list;PRAGMA table_list shows every table and view with its column countLists all tables and views of a SQLite database with type, column count and strict flag.2 Dec 2026 - Tip
SELECT unixepoch('2026-01-01 00:00:00');SQLite unixepoch() turns any date string into Unix secondsConverts a date or time string into a Unix timestamp directly in SQL.2 Dec 2026 - Tip
SELECT name, iif(qty > 0, 'in stock', 'sold out') AS stateSQLite iif() is a short CASE expression with several branchesPicks a value based on conditions, without writing a full CASE expression.2 Dec 2026 - Tip
sqlite3 -bail app.db < migrate.sqlsqlite3 -bail stops a SQLite script at the first errorMakes a SQL script stop at the first failing statement instead of running the rest.30 Nov 2026 - Tip
CREATE INDEX 'orders_user_id' ON 'orders'('user_id'); --> users(id).lint fkey-indexes finds SQLite foreign keys that have no indexLists foreign key columns without an index and prints the CREATE INDEX to fix each one.30 Nov 2026 - Tip
CREATE INDEX users_active_email ON users(email) WHERE active = 1;A partial index in SQLite only covers the rows your queries ask forIndexes only rows that match a WHERE clause, so the index stays small and fast.30 Nov 2026 - Tip
sqlite> .once users.csv.once sends the next SQLite query result to a file and then stopsWrites one query result to a file from inside the shell, then output goes back to the screen.30 Nov 2026 - Tip
DELETE FROM users WHERE active = 0 RETURNING id, email;RETURNING gives you the rows a SQLite INSERT, UPDATE or DELETE touchedGets back ids and values of changed rows from the same statement that changed them.30 Nov 2026 - Tip
sqlite3 app.db "PRAGMA auto_vacuum = INCREMENTAL; VACUUM;"Auto_vacuum INCREMENTAL lets SQLite give space back in small stepsSets a SQLite file up so you can return free pages to disk without a full VACUUM.30 Nov 2026 - Tip
sqlite3 app.db "PRAGMA wal_checkpoint(TRUNCATE);"PRAGMA wal_checkpoint(TRUNCATE) shrinks a SQLite -wal file that keeps growingMoves everything from the write-ahead log into the main file and resets the log to zero bytes.30 Nov 2026 - Tip
sqlite3 app.db ".sha3sum".sha3sum in the sqlite3 shell compares the content of two SQLite filesHashes the rows of a SQLite file so two copies can be compared regardless of file layout.30 Nov 2026 - Tip
sqlite3 app.db ".dump users" > users.sql.dump with a table name exports one SQLite table as SQLWrites the CREATE and INSERT statements for just one table to move it to another file.30 Nov 2026 - Tip
email TEXT COLLATE NOCASE UNIQUECOLLATE NOCASE on a SQLite column makes email lookups ignore caseDeclares a column case-insensitive so comparisons, uniqueness and its index ignore case.30 Nov 2026 - Tip
sqlite3 -header app.db "SELECT * FROM pragma_page_count, pragma_freelist_count, pragma_page_size;"PRAGMA freelist_count tells you how much a SQLite VACUUM would give backChecks how many empty pages a SQLite file holds before you rebuild it.30 Nov 2026 - Tip
SELECT prefs ->> 'theme', prefs -> 'theme', prefs ->> '$.lang'The ->> operator reads a value from JSON in SQLite without json_extractPulls fields out of a JSON column with short arrow syntax instead of function calls.30 Nov 2026 - Tip
INSERT INTO counter VALUES ('home', 1)INSERT … ON CONFLICT DO UPDATE is the SQLite upsert in one statementInserts a row or updates the existing one in a single statement, without a SELECT first.30 Nov 2026 - Tip
sqlite> .parameter set :mail '[email protected]'.parameter set lets you test SQLite queries with named parameters in the shellBinds values to :name placeholders so you can run an app's query exactly as written.30 Nov 2026 - Tip
sqlite> ATTACH 'old.db' AS old;ATTACH lets one SQLite session query and copy across two filesOpens a second SQLite file under a name so you can join or copy between both.30 Nov 2026 - Tip
CREATE VIRTUAL TABLE notes USING fts5(title, body);An FTS5 table gives SQLite real full-text search with rankingSearches text by words and prefixes with ranked results instead of slow LIKE scans.30 Nov 2026 - Tip
sqlite3 broken.db ".recover" | sqlite3 recovered.dbsqlite3 .recover rescues rows from a corrupt database where .dump gives upRebuilds a new SQLite database from every readable page of a damaged file.28 Nov 2026 - Tip
sqlite> PRAGMA foreign_keys = ON;PRAGMA foreign_keys = ON makes SQLite actually enforce foreign keysTurns on foreign key enforcement for a SQLite connection, since it is off by default.28 Nov 2026 - Tip
sqlite> PRAGMA busy_timeout = 5000;PRAGMA busy_timeout makes SQLite wait for a lock instead of failing at onceSets how long a SQLite connection waits for a locked database before it reports an error.28 Nov 2026 - Tip
sqlite3 app.db "PRAGMA optimize;"PRAGMA optimize lets SQLite refresh its statistics only where it needs toUpdates SQLite's query planner statistics only for tables where that is likely to help.28 Nov 2026 - Tip
sqlite> .expertsqlite3 .expert suggests the index a slow query is missingProposes missing indexes for a query you type in the SQLite shell.28 Nov 2026 - Tip
sqlite3 app.db "PRAGMA user_version = 3;"PRAGMA user_version gives a SQLite file a built-in schema version numberReads or sets a free integer in the SQLite file header, handy for tracking the schema version.28 Nov 2026 - Tip
sqlite3 app.db "PRAGMA journal_mode=WAL;"PRAGMA journal_mode=WAL lets SQLite read and write at the same timeSwitches a SQLite database to write-ahead logging, so readers and a writer stop blocking each other.27 Nov 2026 - Tip
CREATE TABLE readings (STRICT tables make SQLite reject the wrong data typeMakes a SQLite table refuse values that don't match the column's declared type.27 Nov 2026 - Tip
.timer on.timer on makes the sqlite3 shell show how long each query tookPrints the time each statement took in the sqlite3 shell, so you can compare queries.27 Nov 2026 - Tip
sqlite3 -readonly db.sqlitesqlite3 -readonly opens a database without any chance of changing itOpens an SQLite database file in read-only mode, so a stray UPDATE or DELETE just returns an error.25 Nov 2026 - Tip
.mode column.headers on and .mode column make sqlite3 output readableShows sqlite3 query results as aligned columns with their names above them.19 Nov 2026
Media1
Storage1
Nothing matches.