sqlite数据库简单操作

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:sqlite数据库简单操作

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

sqlite创建库并创建表插入数据

E:\RECOVER\sqllite>sqlite3
SQLite version 3.48.0 2025-01-14 11:05:00
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open test.db
sqlite> create table t1(id int)
   ...> ;
sqlite> insert into t1 values(1);
sqlite> insert into t1 values(2);
sqlite> insert into t1 values(23;
sqlite> insert into t1 values(23);
sqlite> select * from t1;
1
2
23

sqlite> .q

sqlite导出数据(在sqlite库部分有损坏的情况下也可以导出)

E:\RECOVER\sqllite>sqlite3
SQLite version 3.48.0 2025-01-14 11:05:00
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open test.db
sqlite> select * from t1;
1
2
23
sqlite> .mode insert
sqlite> .output dbdump.sql
sqlite> .dump
sqlite> .exit

E:\RECOVER\sqllite>

sqlite导入数据

E:\RECOVER\sqllite>sqlite3
SQLite version 3.48.0 2025-01-14 11:05:00
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open test2.db
sqlite> .read dbdump.sql
sqlite> select * from t1;
1
2
23
sqlite> .exit

E:\RECOVER\sqllite>

对于损坏的sqlite数据库也可以采用此方法进行尝试