Last active
October 13, 2015 22:28
-
-
Save AJ-Acevedo/4265713 to your computer and use it in GitHub Desktop.
Basic Syntax for sqlite3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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