SQLite Tips
I've been playing around with SQLite recently and I've stumbled across a few things I want to remember, so I'm putting them here.
The SQLite CLI is pretty darn good. Just remember to read in the SQLite DB file first, e.g.
.open /path/to/file. After that, any SQLite command is valid. Specific CLI commands are prefixed with a period.Set the the
.modetolineto visually grep the results.To see the
rowidinclude it specifically inSELECTstatements on the CLI, e.g.SELECT rowid,* from table.Delete an entry by
rowidlike this,DELETE FROM table WHERE rowid=7;When structuring a database, create a unique ID for each row like so:
create table foo (id INTEGER AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, other_column TEXT).View all tables via
.tables.View schema for a table via
.schema TABLENAME.
That's all I got for now. I'll drop more tips in this post as I come across them.