Académique Documents
Professionnel Documents
Culture Documents
(Complete Recovery and Only will loose the un commited transactions. Loss of undo
datafile need the database outage)
1. I have created one temporary table for testing.
SQL> create table dba_segments_new as select * from dba_segments;
Table created.
1A. I have inserted the data into table and not commited.
SQL>insert into dba_segments_new select * from dba_segments_new;
4488 rows created.
SQL> /
8976 rows created.
SQL> /
17952 rows created.
SQL> /
35904 rows created.
SQL> select count(1) from dba_segments_new;
COUNT(1)
----------
71808
1B. Here we can see the undo segments active and expired info below.
SQL> select tablespace_name,status,sum(bytes) from dba_undo_extents group by
tablespace_name,status;
TABLESPACE_NAME STATUS SUM(BYTES)
------------------------------ --------- ----------
UNDOTBS1 ACTIVE 1179648
UNDOTBS1 EXPIRED 5505024
SQL> select file_name from dba_data_files where tablespace_name='UNDOTBS1';
FILE_NAME
--------------------------------------------------------------------------------
/restore1/oracle/SID/data/SID_undotbs01.dbf
2. I have deleted the undo tablespace datafile at OS level. Below are the details.
Ls -ltr
total 4315312
-rw-r--r-- 1 oracle dba 5017 Oct 26 13:25 abcd-
rw-r----- 1 oracle dba 52436992 Oct 29 06:05 SID_users01.dbf
-rw-r----- 1 oracle dba 104865792 Oct 29 06:05 SID_autoindexes01.dbf
-rw-r----- 1 oracle dba 524296192 Oct 29 06:05 SID_autodata01.dbf
-rw-r----- 1 oracle dba 524296192 Oct 29 07:39 SID_sysaux01.dbf
-rw-r----- 1 oracle dba 209723392 Oct 29 07:44 SID_undotbs01.dbf
-rw-r----- 1 oracle dba 734011392 Oct 29 07:50 SID_system01.dbf
-rw-r----- 1 oracle dba 10486272 Oct 29 07:50 SID_redo02b.log
-rw-r----- 1 oracle dba 10486272 Oct 29 07:50 SID_redo02a.log
-rw-r----- 1 oracle dba 10486272 Oct 29 07:50 SID_redo01b.log
-rw-r----- 1 oracle dba 10486272 Oct 29 07:50 SID_redo01a.log
-rw-r----- 1 oracle dba 5881856 Oct 29 07:53 SID_control03.ctl
-rw-r----- 1 oracle dba 5881856 Oct 29 07:53 SID_control02.ctl
-rw-r----- 1 oracle dba 5881856 Oct 29 07:53 SID_control01.ctl
rm SID_undotbs01.dbf
3. After deleting the undo tablespace datafile, again I have insrted the data into
table and finally got the below error.
SQL> select count(1) from dba_segments_new;
COUNT(1)
----------
71808
SQL> insert into dba_segments_new select * from dba_segments_new;
71808
rows created.
SQL> /insert into dba_segments_new
select * from dba_segments_new
*ERROR at line 1:ORA-01116: error in opening database file 2
ORA-01110: data file 2: '/restore1/oracle/SID/data/SID_undotbs01.dbf'
ORA-27041: unable to open fileIBM AIX RISC System/6000 Error: 2: No such file or
directoryAdditional information: 3
4. Shut down the database using shut abort.
SQL> shut abort
ORACLE instance shut down.
5. Connect to RMAN and mount the database (If we have rman backup).
RMAN> startup mount;
Oracle instance starteddatabase mounted
Total System Global Area 838860800 bytes
Fixed Size 2074928 bytes
Variable Size 503318224 bytes
Database Buffers 327155712 bytes
Redo Buffers 6311936 bytes
6. Offline the datafile which is lost
RMAN> alter database datafile 2 offline;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "datafile": expecting one of: "mount, open"
RMAN-01007: at line 1 column 16 file: standard input
RMAN>
Note: Got the above error because of syntax error.
RMAN> sql 'alter database datafile 2 offline';
sql statement: alter database datafile 2 offline
7. Restore the datafile:
RMAN> restore datafile 2;
Starting restore at 29-OCT-09using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring
datafile 00002 to /restore1/oracle/SID/data/SID_undotbs01.dbf
channel ORA_DISK_1: reading from backup piece
/restore1/oracle/SID/backup/SID_20091013_700141178_4889_1_L0.dbf
channel ORA_DISK_1: restored backup piece 1piece
handle=/restore1/oracle/SID/backup/SID_20091013_700141178_4889_1_L0.dbf
tag=TAG20091013T113938
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07Finished restore at 29-
OCT-09
11. We can see the unexpired undo segments above but will lose all the un commited
transactions. Below we can see only commited transactions.
SQL> select count(1) from dba_segments_new;
COUNT(1)
----------
4488