sqlite3 [options] [databasefile] ['SQLstatments']
Terminal-based front-end to the SQLite library that can evaluate queries interactively and display the
results in multiple formats.
Uses dbname.db, .db-shm and .db-wal
Can be used within shell scripts and other applications to provide batch processing features.
-init file | execute file , containng SQL and meta-commands.
| ||||||||||||||||||
-echo |
sqlite3 db "vacuum;"
can be used to "clean up" the database.
If the database file does not exist, it will be silently created (i.e. no message like "database does not exist is displayed").
Example: create a new database file named mydata.db
, create a table named memos
and insert a couple of records into it;
$ sqlite3 mydata.db -column -header SQLite version 3.7.13 with MAC OSX Mavericks 10.9 Enter ".help" for instructions sqlite> create table memos(text, priority INTEGER); sqlite> insert into memos values('deliver project description', 10); sqlite> insert into memos values('lunch with Chris', 100); sqlite> select * from memos order by priority; text priority --------------------------- ---------- deliver project description 10 lunch with Chris 100 sqlite>
ATTACH
to existing or create new database files orSQL statements (separated by semi-colons) can be supplied as an argument. For example:
sqlite3 -line mydata.db 'select * from memos where priority>20; text=lunch with Chris priority=100'
\
.
sqlite> .help rearranged by ed .databases List names and files of attached databases .tables [?TABL?] List names of tables If TABL specified, only list tables matching LIKE pattern TABL. .schema [?TABL?] Show the CREATE statements If TABL specified, only show tables matching LIKE pattern TABL. .dump ?TABL? ... Dump the database in an SQL text format If TABL specified, only dump tables matching LIKE pattern TABL. .read FILENAME Execute SQL in FILENAME .echo ON|OFF .output FILENAME .output stdout .explain ON|OFF Turn output mode suitable for EXPLAIN on or off.default on .import FILE TABLE Import data from FILE into TABLE .indices ?TABL? Show names of all indices If TABL specified, only show indices for tables matching LIKE pattern TABL. .log FILE|off Turn logging on or off. FILE can be stderr/stdout .mode MODE ?TABL? Set output mode where MODE is one of:
csv |
.header(s) ON|OFF Turn display of headers on or off .width NUM1 NUM2 ... Set column widths for "column" mode .bail ON|OFF Stop after hitting an error. Default OFF .prompt MAIN CONTINUE Replace the prompts .backup ?DB? FILE default "main" .restore ?DB? FILE default "main" .nullvalue STRING Print STRING in place of NULL values .separator STRING Change separator used by output mode and .import .show current values for various settings echo: off eqp: off explain: off headers: off mode: list nullvalue: "" output: stdout colseparator: "|" rowseparator: "\n" stats: off width: .stats ON|OFF Turn stats on or off .timeout MS Try opening locked tables for MS milliseconds .trace FILE|off Output each SQL statement as it is run .vfsname ?AUX? Output the name of the VFS stack unix .timer ON|OFF Turn the CPU timer measurement on or off Run Time: real 0.001 user 0.000098 sys 0.000046 .exit .quit .help
mode = LIST separator = "|" main prompt = "sqlite> " continue prompt = " ...> "
~/.sqliterc
if it is readable, (It should generally only contain meta-commands.)
-init file
if it is readable
~/.bin/0ShowQuarantineEvents.sh
~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2CREATE TABLE LSQuarantineEvent (
LSQuarantineEventIdentifier TEXT PRIMARY KEY NOT NULL,
LSQuarantineTimeStamp REAL, yuck
LSQuarantineAgentBundleIdentifier TEXT,
LSQuarantineAgentName TEXT,
LSQuarantineDataURLString TEXT,
LSQuarantineSenderName TEXT,
LSQuarantineSenderAddress TEXT,
LSQuarantineTypeNumber INTEGER,
LSQuarantineOriginTitle TEXT,
LSQuarantineOriginURLString TEXT,
LSQuarantineOriginAlias BLOB );
CREATE INDEX LSQuarantineEventIndex ON LSQuarantineEvent ( LSQuarantineEventIdentifier );