Oracle Database Simulated Data File Corruption recovery

Source: Internet
Author: User
Sometimes the database cannot be started because the data file is damaged for some reason. How can this problem be recovered? The following is a simulation experiment. 1. first create a tablespace TEST, and then create a table test in the tablespace test

Sometimes the database cannot be started because the data file is damaged for some reason. How can this problem be recovered? The following is a simulation experiment. 1. first create a tablespace TEST, and then create a table test in the tablespace test

Sometimes the database cannot be started because the data file is damaged for some reason. How can this problem be recovered?

The following is a simulated experiment with server space:

1. First create a tablespace TEST, and then create a table test on the tablespace test.

SQL> create tablespace test datafile '/u01/app/oracle/oradata/lhz/test01.dbf' size 10 M;


SQL> create table test as select * from dba_objects;

Table created

SQL> alter table test move tablespace test;

Table altered

SQL> select count (*) from test;


COUNT (*)

----------

50881


2. Then use vi to edit the data file

[Oracle @ odb1 ~] $ Vi/u01/app/oracle/oradata/lhz/test01.dbf

3. Enter any characters and save them.

4. Shut down database instances

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

5. Start the instance

SQL> startup

ORACLE instance started.


Total System Global Area 599785472 bytes

Fixed Size 2098112 bytes

Variable Size 243272768 bytes

Database Buffers 348127232 bytes

Redo Buffers 6287360 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 9-see DBWR trace file

ORA-01110: data file 9: '/u01/app/oracle/oradata/lhz/test01.dbf'


The error message indicates that the data file cannot be verified or the data file cannot be locked.

6. damage the data file offline, server space, and open the database instance

SQL> alter database datafile '/u01/app/oracle/oradata/lhz/test01.dbf' offline;

Database altered.

SQL> alter database open;

Database altered.

7. Add the same tablespace test

SQL> alter database create datafile '/u01/app/oracle/oradata/lhz/test01.dbf ';

Database altered.

SQL> recover datafile 9;

Media recovery complete.

SQL> alter database datafile 9 online;

Database altered.

8. Verify the recovery result:


SQL> select count (*) from andylhz. test;


COUNT (*)

----------

50881


Recovery completed!

This article is from the "shadow server" blog, Hong Kong server. Please keep this source

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.