SQL Server中用于备份的语句

发布时间:2020-09-02编辑:脚本学堂
SQL Server中用于备份的一些语句

本文收集整理了一些SQL Server中用于备份的语句,供大家学习参考。

--完全备份
backup database demo
to nwdevice02
with name = 'fullbak'

--日志备份
backup log demo
to nwdevice02
with name = 'log1'
--restore full backup
restore database demo
from nwdevice02
with file=1,norecovery
--restore log backup
restore log demo
from nwdevice02
with file=4,recovery
 
--完全备份
  backup database demo
  to nwdevice
  with name='完全备份'

--差异备份
  backup database demo
  to nwdevice
  with differential,
       name = '差异备份1'
 
--日志备份 log1
  backup log demo
  to nwdevice
  with name='日志1'

--日志备份 log2
  backup log demo
  to nwdevice
  with name='日志2'

--还原完全备份
  restore database demo
  from nwdevice
  with norecovery  --相当于第二项(选项)
       file = 1

--还原差异备份
  restore database demo
  from nwdevice
  with recovery,
       file= 2
 /* 第一完全备,第二次差异备份*/

--还原日志
  restore log demo
  from nwdevice
  with file= 2,
       norecovery
restore log demo
from nwdevice
with file= 3,
recovery