sqlite 如何建立数据库,打开数据库,存储到数据库

  • 一开始安装sqlite教程建立数据库,关闭cmd再打开,.databases 看不到数据库,也找不到建立的数据库文件

新建数据库

  • 是从cmd文件中 sqlite3 test.db,注意不是从从sqlite中去建立数据库
  • tips: 通过node 操作过数据库,添加记录,cmd连接sqlite,直接查找未立即生效!!

建立数据库,存储需要有表文件和数据

C:\Windows\system32>sqlite3 test.db
SQLite version 3.38.5 2022-05-06 15:25:27
Enter ".help" for usage hints.
sqlite> .databases
main: C:\Windows\system32\test.db r/w
sqlite> create table test1(id integer,value text);
sqlite> insert into test1(id,value) values(1,'LiKeNeng');
sqlite> create table test2(id integer,value text);
sqlite> insert into test2(id,value) values(2,'LiuXue');
sqlite> select * from test1;
1|LiKeNeng
sqlite> select * from test2;
2|LiuXue

备份数据库

sqlite> .backup E:/sqlite/test.db

重新打开sqlite3 ,找到并使用数据库

sqlite> .restore 'E:\sqlite\test.db'
sqlite> .tables
test1  test2
sqlite> select * from test1;
1|LiKeNeng
sqlite> select * from test2;
2|LiuXue
posted @ 2022-06-16 13:56  盘思动  阅读(390)  评论(0编辑  收藏  举报