获取SQL Server Compact数据库的“备份”

时间:2021-12-07 15:06:31

Is it possible to take Backup of SQL Server Compact database (i.e. *.sdf) and Restore the same.

是否可以使用备份SQL Server Compact数据库(即* .sdf)并恢复它。

2 个解决方案

#1


10  

Just copy the file. Done.

只需复制文件即可。完成。

Quote from Maintaining Databases:

来自维护数据库的报价:

Because SQL Server Compact 3.5 is a file-based database system, you can accomplish many common database tasks such as backing up, restoring, and deleting a database by using the file system APIs.

由于SQL Server Compact 3.5是基于文件的数据库系统,因此您可以使用文件系统API完成许多常见的数据库任务,例如备份,还原和删除数据库。

To back up a database, close all connections to the database, and then copy the .sdf file. To restore a database, copy the .sdf file back to its regular working location. These operations work even if the database is set up for replication. To drop a database, delete the .sdf database file.

要备份数据库,请关闭与数据库的所有连接,然后复制.sdf文件。要还原数据库,请将.sdf文件复制回其常规工作位置。即使数据库已设置为要复制,这些操作也会起作用。要删除数据库,请删除.sdf数据库文件。

#2


2  

I write the compact SQL database out to an XML file using LINQ to SQL and read it back in to restore it.

我使用LINQ to SQL将紧凑型SQL数据库写入XML文件,并将其读回以恢复它。

#1


10  

Just copy the file. Done.

只需复制文件即可。完成。

Quote from Maintaining Databases:

来自维护数据库的报价:

Because SQL Server Compact 3.5 is a file-based database system, you can accomplish many common database tasks such as backing up, restoring, and deleting a database by using the file system APIs.

由于SQL Server Compact 3.5是基于文件的数据库系统,因此您可以使用文件系统API完成许多常见的数据库任务,例如备份,还原和删除数据库。

To back up a database, close all connections to the database, and then copy the .sdf file. To restore a database, copy the .sdf file back to its regular working location. These operations work even if the database is set up for replication. To drop a database, delete the .sdf database file.

要备份数据库,请关闭与数据库的所有连接,然后复制.sdf文件。要还原数据库,请将.sdf文件复制回其常规工作位置。即使数据库已设置为要复制,这些操作也会起作用。要删除数据库,请删除.sdf数据库文件。

#2


2  

I write the compact SQL database out to an XML file using LINQ to SQL and read it back in to restore it.

我使用LINQ to SQL将紧凑型SQL数据库写入XML文件,并将其读回以恢复它。