我正在使用System.Data.SQLite.dll
来使用SQLite内存数据库。程序结束后,我想将内存数据库转储到.db3文件以供下次使用。如何在C#中实现这一点?
我正在使用System.Data.SQLite.dll
来使用SQLite内存数据库。程序结束后,我想将内存数据库转储到.db3文件以供下次使用。如何在C#中实现这一点?
Obtain SQL statements to create new database structure.
select sql from sqlite_master where name not like 'sqlite_%';
Obtain names of all user tables.
select name
from sqlite_master
where type='table' and name not like 'sqlite_%';
Create the on-disk database in some new SQLiteConnection.
Execute all previously obtained SQL statements to create the database structure in the on-disk database.
Close the separate connection to the on-disk database.
Attach the on-disk database to the in-memory database.
attach 'ondisk.db3' as 'ondisk';
For each user table obtained earlier, copy the content from the in-memory to the on-disk database.
insert into ondisk.TableX select * from main.TableX;
insert into ondisk.TableY select * from main.TableY;
// 进行插入、更新等操作... // 如何将数据转储到文件中? conn.Close();
} </code> - xiagao1982