我正在研究数据库的文件组备份。我要备份和还原PRIMARY文件组中的所有表,而没有SECONDARY文件组中的表。当刚刚编辑表时,我的查询工作正常,但是当它们被截断时,将还原SECONDARY文件组中的表。
当我对SECONDARY文件组中的表进行“ DELETE FROM”修改时,它在还原后保持这种状态。但是,当我在同一张表上执行“ TRUNCATE TABLE”时,所有内容在还原后会返回。我怀疑SECONDARY文件组中的表仍由PRIMARY备份,但这并没有太大意义,因为删除行没有恢复。
--- Create PRIMARY file group backup ---
Use master
BACKUP DATABASE database_name
FILEGROUP = 'PRIMARY'
TO DISK = 'some_location'
--- Restore PRIMARY file group ---
USE master
RESTORE DATABASE database_name
FILEGROUP = 'PRIMARY'
FROM DISK = 'some_location'
WITH PARTIAL, RECOVERY, REPLACE
--- Restore the other filegroup using a recovery-only database restore ---
USE master
RESTORE DATABASE database_name
FILEGROUP = 'SECONDARY'
WITH RECOVERY