cheat-fork-echo/cheat/cheatsheets/sqlite3
2016-09-09 12:05:08 +12:00

20 lines
No EOL
553 B
Text

# create database and launch interactive shell
sqlite3 example.db
# create table
sqlite3 example.db "CREATE TABLE Os(ID INTEGER PRIMARY KEY, Name TEXT, Year INTEGER);"
# insert data
sqlite3 example.db "INSERT INTO 'Os' VALUES(1,'Linux',1991);"
# list tables
sqlite3 example.db ".tables"
# view records in table
sqlite3 example.db "SELECT * FROM 'Os';"
# view records in table conditionally
sqlite example.db "SELECT * FROM 'Os' WHERE Year='1991';"
# view records with fuzzy matching
sqlite3 ~/example.db "SELECT * FROM 'Os' WHERE Year like '19%';"