brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: .headers on and .mode column make sqlite3 output readable

Sqlite
~/tips/sqlite-mode

.mode column

Shows sqlite3 query results as aligned columns with their names above them.

The default sqlite3 output is rows separated by pipe characters, with no column names. I find that hard to read after about three columns.

sqlite3 app.db
.headers on
.mode column
SELECT * FROM users LIMIT 5;

.headers on prints the column names, and .mode column lines the values up under them. SQLite 3.33 and newer also has .mode box, which draws a table with borders.

While you are in there, .tables lists the tables and .schema users shows how one was created. These are shell commands of sqlite3 itself, so they start with a dot and need no semicolon.

Caveat: the settings last for the session only. Put the same lines in ~/.sqliterc to keep them.

Further reading: SQLite command line shell

More Sqlite tips SELECT unixepoch('2026-01-01 00:00:00'); SELECT name, iif(qty > 0, 'in stock', 'sold out') AS state sqlite3 -bail app.db < migrate.sql CREATE INDEX 'orders_user_id' ON 'orders'('user_id'); –> users(id) CREATE INDEX users_active_email ON users(email) WHERE active = 1; All Sqlite tips (27) All topics

Link