Recovering an incorrectly deleted Oracle data file using a file handle ____oracle

Source: Internet
Author: User

Environment Description:
Operating system: Linux
Database version: 11.2.0.4

begin~ CREATE TABLE Spaces TEST_TB

sql> Create tablespace test_tb datafile '/u01/app/oracle/oradata/prod/test.dbf ' size 50M;

Tablespace created.
Create user test
Sql> create user test identified by Oracle default Tablespace TEST_TB;

User created.
Give User test Authorization
Sql> Grant CONNECT,RESOURCE,DBA to test;

Grant succeeded.
CREATE TABLE T1
Sql> Conn test/oracle
Connected.

Sql> CREATE TABLE T1 as select * from Dba_objects;

Table created.
Sql> Select COUNT (*) from T1;

  COUNT (*)
----------
     82347
View Database Archive mode
Sql> Archive Log list
Database log mode          No archive mode
Automatic archival         Disabled
Archive Destination        use_db_recovery_file_dest
oldest online log sequence the current
log sequence           67
To boot the database to mount state
sql> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
sql> Startup Mount
ORACLE instance started.

Total System Global area 1252663296 bytes
Fixed Size          2252824 bytes
Variable Size         788533224 bytes< C20/>database buffers      452984832 bytes Redo buffers the 8892416            Database bytes
.
Open Archive
sql> ALTER DATABASE archivelog;

Database altered.
Open Database
sql> ALTER DATABASE open;

Database altered.
Verify that the archive is turned on
Sql> Archive Log list
Database log mode          archive mode
Automatic archival         Enabled
Archive Destination        use_db_recovery_file_dest
oldest online log sequence
Next log sequence to archive   Current
log sequence           67
Analog mistakenly delete data file test.dbf
[Oracle@vastdata1 ~]$ rm-f/u01/app/oracle/oradata/prod/test.dbf
Inserting data into the T1 table failed again
sql> INSERT INTO T1 select * from Dba_objects;
INSERT INTO T1 SELECT * Dba_objects
            * ERROR at line
1:
ora-01116:error in opening database file 5
  ora-01110:data file 5: '/u01/app/oracle/oradata/prod/test.dbf '
ora-27041:unable to open file
linux-x86_ Error:2: No Such file or directory
Additional Information:3
The database is not closed at this time and can be recovered using a handle
[Oracle@vastdata1 ~]$ ps-ef |grep-v grep |grep dbw0 Oracle 37300 1 0 17:45? 00:00:00 Ora_dbw0_prod [oracle@vastdata1 ~]$ cd/proc/37300/fd [oracle@vastdata1 fd]$ ll Total 0 lr-x------1 Oracle Oinst All may 17:53 0->/dev/null l-wx------1 Oracle Oinstall 17:53 1->/dev/null lrwx------1 Oracle O  Install 17:53->/u01/app/oracle/product/11.2.0/dbhome_1/dbs/lkprod lr-x------1 Oracle Oinstall May 26 17:53->/U01/APP/ORACLE/PRODUCT/11.2.0/DBHOME_1/RDBMS/MESG/ORAUS.MSB l-wx------1 Oracle Oinstall-26 17:53 2->/dev/null lrwx------1 Oracle Oinstall 17:53 256->/u01/app/oracle/oradata/prod/control01.ctl lrwx--  ----1 Oracle oinstall 17:53 257->/u01/app/oracle/fast_recovery_area/prod/control02.ctl lrwx------1 Oracle  Oinstall 17:53 258->/u01/app/oracle/oradata/prod/system01.dbf lrwx------1 Oracle Oinstall 26 17:53 259->/u01/app/oracle/oradata/prod/sysaux01.dbF lrwx------1 Oracle oinstall 17:53->/u01/app/oracle/oradata/prod/undotbs01.dbf lrwx------1 Oracle Oi  Nstall 17:53 261->/u01/app/oracle/oradata/prod/users01.dbf lrwx------1 Oracle Oinstall 26 17:53 262 ->/u01/app/oracle/oradata/prod/test.dbf (Deleted) lrwx------1 Oracle Oinstall (May) 17:53 263->/u01/app/ora  CLE/ORADATA/PROD/TEMP01.DBF lr-x------1 Oracle Oinstall 1 May 17:53 3->/dev/null lr-x------Oracle Oinstall 64 May 17:53 4->/dev/null lr-x------1 Oracle Oinstall could 17:53 5->/dev/null lr-x------1 Oracle Oinstal  L/May 17:53 6->/U01/APP/ORACLE/PRODUCT/11.2.0/DBHOME_1/RDBMS/MESG/ORAUS.MSB lr-x------1 Oracle Oinstall 17:53 7->/proc/37300/fd lr-x------1 Oracle Oinstall may 17:53 8->/dev/zero lrwx------1 Oracle Oinsta ll/May 17:53 9->/u01/app/oracle/product/11.2.0/dbhome_1/dbs/hc_prod.dat
Restore deleted files to their original location using the CP command
[Oracle@vastdata1 fd]$ CP 262/u01/app/oracle/oradata/prod/test.dbf
The database has always been open, the SCN constantly changing, will test.dbf file offline
sql> ALTER DATABASE datafile '/U01/APP/ORACLE/ORADATA/PROD/TEST.DBF ' offline;

Database altered.
The data files recovered with CP are inconsistent with the current information of the database and require recover
sql> recover datafile '/u01/app/oracle/oradata/prod/test.dbf ' 
Media recovery complete.
TEST.DBF file online after recover is complete
sql> ALTER DATABASE datafile '/u01/app/oracle/oradata/prod/test.dbf ' online;

Database altered.
Restart the database
sql> conn/as sysdba
Connected.
sql> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
Sql> Startup
ORACLE instance started.

Total System Global area 1252663296 bytes
Fixed Size          2252824 bytes
Variable Size         788533224 bytes
database buffers      452984832 bytes
Redo buffers 8892416
database bytes.
Database opened.
Test
Sql> Conn test/oracle
Connected.
Sql> Select COUNT (*) from T1;

  COUNT (*)
----------
     82347

Note: The database is in archive mode, the database, operating system does not restart, if the database or operating system is shut down this way is not appropriate.

end~

Related Article

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.