Skip to content

Instantly share code, notes, and snippets.

@AJ-Acevedo
Last active October 13, 2015 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AJ-Acevedo/4265713 to your computer and use it in GitHub Desktop.
Save AJ-Acevedo/4265713 to your computer and use it in GitHub Desktop.
Basic Syntax for sqlite3
Basic Syntax for sqlite3
# Navigate to the directory where the sqlite database files are located
$ cd /workingDIR
# Initiate a connection with the database
$ sqlite3 databasename.sqlite3
# Show tables
> .tables
# Display table schema
> .schema tablename
# Print table data
> SELECT * FROM tablename
# show list of available sqlite commands
> .help
# Exit the sqlite session
> .exit
# Copy an sqlite3 database that is currently in use
# NOTE: begin immediate; will set the database to read-only until you run rollback;
$ sqlite3 databasename.sqlite3
sqlite> begin immediate;
<press CTRL+Z>
$ cp -a databasename.sqlite3 databasename.sqlite3.backup
$ fg
sqlite> rollback;
sqlite> .exit
Reference:
Command Line Shell For SQLite - http://www.sqlite.org/sqlite.html
SQL As Understood By SQLite - http://www.sqlite.org/lang_transaction.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment