写出使用差异备份方法备份数据库YGGL到备份设备CPYGBK中的T-SQL语句
时间: 2023-12-23 16:03:34 浏览: 81
flash+完整代码
好的,以下是使用T-SQL语句进行差异备份的示例:
1. 进行整备份
```
UP DATABASE YGGL DISK = 'CPYGBK:\YGGL_FULL.BAK' WITH INIT;
```
2. 进行第一次差异备份
```
BACKUP DATABASE YGGL TO DISK = 'CPYGBK:\YGGL_DIFF_1.BAK' WITH DIFFERENTIAL;
```
3. 进行增量备份
```
BACKUP DATABASE YGGL TO DISK = 'CPYGBK:\YGGL_INC_1.BAK' WITH INCREMENTAL;
```
4. 恢复数据时,先将最近的差异备份和增量备份合并,再与最近的完整备份合并
```
RESTORE DATABASE YGGL FROM DISK = 'CPYGBK:\YGGL_FULL.BAK'
WITH NORECOVERY;
RESTORE DATABASE YGGL FROM DISK = 'CPYGBK:\YGGL_DIFF_1.BAK'
WITH NORECOVERY;
RESTORE DATABASE YGGL FROM DISK = 'CPYGBK:\YGGL_INC_1.BAK'
WITH NORECOVERY;
RESTORE DATABASE YGGL WITH RECOVERY;
```
需要注意的是,备份文件的路径和名称可以根据实际情况进行修改。同时,增量备份的备份方式为“INCREMENTAL”,而不是“DIFFERENTIAL”。
阅读全文