日期:2014-05-18 浏览次数:20629 次
-- 建测试数据库wangl create database wangl -- 改为简单恢复模式 alter database wangl set recovery simple -- 打开数据库wangl use wangl -- 建测试表wangl001 create table wangl001(id int) -- 插入测试数据(1) insert into wangl001(id) values(1) -- 数据库全备份 backup database wangl to disk='D:\wangl_full.bak' with format,init -- 插入测试数据(2) insert into wangl001(id) values(2) -- 数据库差异备份 backup database wangl to disk='D:\wangl_diff1.bak' with DIFFERENTIAL -- 插入测试数据(3) insert into wangl001(id) values(3) -- 数据库差异备份 backup database wangl to disk='D:\wangl_diff2.bak' with DIFFERENTIAL -- 删除数据库wangl use master drop database wangl -- 用全备份还原,用standby参数 restore database wangl_B from disk='D:\wangl_full.bak' with replace,standby='D:\wangl_temp.trn' -- 可以查询 select * from wangl_B.dbo.wangl001 id ----------- 1 -- 用差异备份还原 restore database wangl_B from disk='D:\wangl_diff1.bak' with standby='D:\wangl_temp.trn' -- 可以查询 select * from wangl_B.dbo.wangl001 id ----------- 1 2 -- 继续用差异备份还原 restore database wangl_B from disk='D:\wangl_diff2.bak' with standby='D:\wangl_temp.trn' -- 依然可以查询 select * from wangl_B.dbo.wangl001 id ----------- 1 2 3 -- 还原为recovery状态. restore database wangl_B from disk='D:\wangl_diff2.bak' with recovery -- 依然可以查询 select * from wangl_B.dbo.wangl001 id ----------- 1 2 3