Using Sqlite from the command-line

Here's a few sqlite examples to get you started on using sqlite from the command-line.

Creating the database

sqlite3 test.db "create table t1 (t1key INTEGER PRIMARY KEY,data TEXT,num double,timeEnter DATE);"

Observed the following from the file contents of test.db:

SQLite format 3


CREATE TABLE t1 (t1key INTEGER
PRIMARY KEY,data TEXT,num double,timeEnter DATE)

Creating database records

sqlite3 test.db "insert into t1 (data,num) values ('This is sample data',3);"
sqlite3 test.db "insert into t1 (data,num) values ('More sample data',6);"
sqlite3 test.db "insert into t1 (data,num) values ('And a little more',9);"

Displaying the records

sqlite3 test.db "select * from t1 limit 2";

Observed:

1|This is sample data|3.0|
2|More sample data|6.0|
Tags:
Source:
1154hrs.txt
Published:
20-11-2015 11:54