Sqlite3 Commands

sqlite 的常用命令

Commands

Help

sqlite> .help

Open a database and enter sqlite prompt

$ sqlite3 hello.db
sqlite>

Show all tables

sqlite> .tables 

Show the schema of a table

sqlite> .schema TABLE_NAME

Examples

sqlite> .tables
documents  settings   tokens

sqlite> .schema documents
CREATE TABLE documents (  id      INTEGER PRIMARY KEY,  title   TEXT NOT NULL,  body    TEXT NOT NULL);
CREATE UNIQUE INDEX title_index ON documents(title);

sqlite> .schema tokens
CREATE TABLE tokens (  id         INTEGER PRIMARY KEY,  token      TEXT NOT NULL,  docs_count INT NOT NULL,  postings   BLOB NOT NULL);
CREATE UNIQUE INDEX token_index ON tokens(token);

Tools

LiteCLI
A command line interface for SQLite with auto-completion and syntax highlighting.