Sqlite client

From wikinotes

SQLite uses SQL.

Locations

~/.sqliterc config

Create Database

sqlite3         # in-memory db
sqlite3 new.db  # open/create db

CLI

Config

You can add sqlite commands to your sqliterc.

# ~/.sqliterc
.mode column
.header on

Introspection

.tables                        # list tables in db
.schema table_name             # table definition

See sqlite syntax for PRAGMA commands.


Result Formatting

.mode line    # one line per column
.mode column  # one line per row

.header on    # show column headers

Dump/Restore

# dumps database with data to dump.sql
.output dump.sql
.dump  # optionally, specify just table
.quit
# dump schema only to schema.sql
.output schema.sql
.schema
.quit
# restore from a dump
.read schema.sql
.quit