Home > Database > Mysql Tutorial > sql server通过日志恢复数据库

sql server通过日志恢复数据库

WBOY
Release: 2016-06-07 16:18:20
Original
1026 people have browsed it

--创建测试数据库Test create database Test on primary ( name=Test_data.mdf, filename=d:Test_data.mdf ) log on ( name=Test_data.ldf, filename=d:Test_data.ldf ) --创建测试表 create table Test.dbo.ta(id int) insert into Test.dbo.ta select id f

   --创建测试数据库Test

  create database Test

  on primary

  (

  name=’Test_data.mdf’,

  filename=’d:Test_data.mdf’

  )

  log on

  (

  name=’Test_data.ldf’,

  filename=’d:Test_data.ldf’

  )

  --创建测试表

  create table Test.dbo.ta(id int)

  insert into Test.dbo.ta select id from sysobjects

  --创建备份文件

  backup database Test to disk=’d:Test.bak’ with format

  --创建一个NDF文件

  alter database Test

  add file

  (

  name=’file’,

  filename=’d:test.ndf’,

  SIZE = 1MB

  )

  --关闭MSSQL服务,,然后删除NDF文件然后再打开MSSQL服务,此时Test数据库被疑置啦!

  --恢复数据疑置

  --首先备份日志文件

  backup log Test to disk=’d:Test_log.bak’ with format,no_truncate

  --利用文件组备份文件恢复被破坏的文件

  restore database Test from disk=’d:Test.bak’ with Norecovery

  --恢复日志文件

  restore Log Test from disk=’d:Test_log.bak’ with RECOVERY

  --TipS

  --如果已经建立ndf文件的话那么恢复日志文件的话用下面的这句话

  --只不过将with RECOVERY-->WITH REPLACE

  restore Log Test from disk=’d:Test_log.bak’ WITH REPLACE

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template