sqlite3 basic reference

C:\sqlite>sqlite3 store.db
SQLite version 3.19.3 2017-06-08 14:26:16
Enter ".help" for usage hints.

Remove a table:

sqlite> DROP TABLE punchlog;

Create a table:

sqlite> CREATE TABLE punchlog(_id INTEGER PRIMARY KEY, date TEXT, punchin TEXT, punchout TEXT, onduty INTEGER, forgotin INTEGER, forgotout INTEGER, latein INTEGER, lateout INTEGER);

List tables:

sqlite> .tables
punchlog

Schema of a table:

sqlite> .schema punchlog
CREATE TABLE punchlog(_id INTEGER PRIMARY KEY, date TEXT, punchin TEXT, punchout TEXT, onduty INTEGER, forgotin INTEGER, forgotout INTEGER, latein INTEGER, lateout INTEGER);

More details on table:

sqlite> PRAGMA TABLE_INFO(punchlog);
0|_id|INTEGER|0||1
1|date|TEXT|0||0
2|punchin|TEXT|0||0
3|punchout|TEXT|0||0
4|onduty|INTEGER|0||0
5|forgotin|INTEGER|0||0
6|forgotout|INTEGER|0||0
7|latein|INTEGER|0||0
8|lateout|INTEGER|0||0
sqlite>

Read data:

SELECT <cols> FROM <table>

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.