数据库文件损坏的恢复方法
Jun 07, 2016 pm 04:19 PM说明如下:SQL Server 2000文件损坏的恢复 1、建一个测试数据库test(数据库类型为完全)。 2、建一个表,插入点记录。 create table a(c1 varchar(2)) go insert into a values('aa') go insert into a values('bb') go 3、作完全备份,到文件test_1.bak。 4
说明如下:SQL Server 2000文件损坏的恢复
1、建一个测试数据库test(数据库类型为完全)。
2、建一个表,插入点记录。
create table a(c1 varchar(2)) go insert into a values('aa') go insert into a values('bb') go
3、作完全备份,到文件test_1.bak。
4、在作一点修改。
insert into a values('cc') go create table b(c1 int) go insert into b values(1) go insert into b values(2) go
5、shutdown 数据库服务器。
SQL Server 2000文件损坏的恢复6、用ultraedit编辑数据库文件test_data.mdf,随便修改点字节内容,相当于数据库遭到致命的损坏。
7、启动数据库,并且运行企业管理器,点开数据库,看到test变成灰色,而且显示置疑。
8、运行isql -SLocalhost -Usa -P。
1> backup log test TO DISK=' D:Program FilesMicrosoft SQL ServerMSSQLBACKUP est_2.bak' WITH NO_TRUNCATE 2>go
已处理2页,这些页属于数据库 'test' 的文件 'TEST_Log'(位于文件 1 上)。
BACKUP LOG 操作成功地处理了 2 页,花费了 0.111 秒(0.087 MB/秒)。
SQL Server 2000文件损坏的恢复9、进行恢复最老的完全备份。
1> RESTORE DATABASE test FROM DISK=' D:Program FilesMicrosoft SQL ServerMSSQL BACKUP est_1.bak' WITH NORECOVERY 2> go
已处理96页,这些页属于数据库 'test' 的文件 'TEST_Data'(位于文件 1 上)。已处理1页,这些页属于数据库 'test' 的文件 'TEST_Log'(位于文件 1 上)。
RESTORE DATABASE 操作成功地处理了 97 页,花费了 0.107 秒(7.368 MB/秒)。
10、恢复最近的日志。
1> RESTORE LOG test FROM DISK=' D:Program FilesMicrosoft SQL ServerMSSQLBACKU P est_2.bak' WITH RECOVERY 2> go
已处理 2 页,这些页属于数据库 'test' 的文件 'TEST_Log'(位于文件 1 上)。
RESTORE LOG 操作成功地处理了 2 页,花费了 0.056 秒(0.173 MB/秒)。
数据已经完全恢复了,可以使用了。
select * from a go
总结,,DBA应该有一个完善的数据库备份计划。本例中,如果没有一个完全备份的话,数据库的恢复就不可能。

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to recover deleted contacts on WeChat (simple tutorial tells you how to recover deleted contacts)

The secret of hatching mobile dragon eggs is revealed (step by step to teach you how to successfully hatch mobile dragon eggs)

How to set font size on mobile phone (easily adjust font size on mobile phone)

The difference between Go language methods and functions and analysis of application scenarios

How to choose a mobile phone screen protector to protect your mobile phone screen (several key points and tips for purchasing mobile phone screen protectors)

Detailed tutorial on establishing a database connection using MySQLi in PHP

How does Hibernate implement polymorphic mapping?

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos
