sqlite数据库是一个轻量级的小型数据库,不需什么额外配置,查询速度快。一般用于本地程序的数据管理,SQLite 数据库通过直接访问其存储文件,后缀名是.db .db3等格式。
在下载后,运行sqlite3.exe就进入了命令操作界面:
sqlite> .quit //退出当前程序
sqlite> .databases //显示当前的所有数据库
sqlite> .tables //显示当前的所有表
sqlite> .save test.db //保存当前的所有表(不包括其他数据库的表)到一个test.db文件
sqlite> attach database "test.db" as "test"; //如果该test.db数据库尚未被创建,上面的命令将创建一个数据库,如果数据库已存在,则把数据库文件与这个test命名 绑定在一起。绑定以后,就可以用该命名使用数据库了。比如test.student,就是这个test数据库表的student表。以后可以直接操作该数据库,就是相当于操作test.db文件了。
sqlite> insert into test.bird (id,swing) select id,age from test.student where id=2; //这句就是通过上边绑定的test数据库名,在bird表里新插入一条记录,使用另外一个student表的记录数据。
sqlite> select * from test.student where id between 1 and 3; //这句是查询student表里id在1和3之间的记录
sqlite> select * from test.student where id in (1,3);//这句是查询student表里id是1和3的两条记录
sqlite> detach database "test"; //把命名数据库test从一个数据库连接分离出来
sqlite> .header on //格式化显示,把列头显示出来
sqlite> .mode column //每列以左对齐方式显示
sqlite> .mode tabs //每列以tab键显示
来源:CSDN
作者:talkingmute
链接:https://blog.csdn.net/talkingmute/article/details/104011404