执行sqlite3进入sqlite3环境:
$ sqlite3 SQLite version 3.8.10.2 2015-05-20 18:17:19 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite>
打开一个文件,如果文件不存在则会创建,之后的操作都是在该文件中进行:
sqlite> .open ./test.db sqlite> .databases seq name file --- --------------- ---------------------------------------------------------- 0 main /Users/palance/Documents/dev/./test.db sqlite>
之后就可以进行增删改查之类的操作了:
sqlite> create table test (id integer primary key, name varchar, url varchar); sqlite> insert into test (id, name, url) values(1, 'xx', '111'); sqlite> select * from test; 1|xx|111
缺少表头,看起来不太舒服,可以这么加上:
sqlite> .headers on sqlite> select * from test; id|name|url 1|xx|111 sqlite>
下次再打开文件可以用如下命令查看其包含了什么库和表:
sqlite> .databases seq name file --- --------------- ---------------------------------------------------------- 0 main /Users/palance/Documents/dev/./test2.db sqlite> .tables test
主要操作就这些。