参考:
http://linux.cn/portal-view-aid-613.html
1、 安装SQLite3
hadron@hadron ~ $ sudo apt-get install sqlite sqlite3
2、 查看版本号
hadron@hadron ~ $ sqlite3 -version
3、 创建test数据库
hadron@hadron ~ $ sqlite3 test.db
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>
4、 查看数据库
sqlite> .database
seq name file
--- --------------- ----------------------------------------------------------
0 main /home/hadron/test.db
5、 创建数据表
sqlite> create table user(id,username,password);
6、 插入数据
sqlite> insert into user(id,username,password) values(1,'abc','123');
7、 查询数据
sqlite> select * from user;
1|abc|123
8、 退出数据库
sqlite> .exit
9、 再次进入数据库
hadron@hadron ~ $ sqlite3
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>
10、安装可视化工具:
hadron@hadron ~ $ sudo apt-get install sqlitebrowser
![](https://i-blog.csdnimg.cn/blog_migrate/b9e3612dac285118734866a9b920dd45.png)
![](https://i-blog.csdnimg.cn/blog_migrate/03d949050c033a0feaaaeeee58495379.png)
这个region.db是我导入的,其中三个表t_provinces t_cities 是有索引的,通过.indices命令可以查看。
至于索引的建立,我是登录sqlite后,利用SQL语句建立的:
create index my_index on my_table(id, user_id);
相应地,drop index和reindex来维护索引。