使用PRM恢复Oracle数据库中误truncate截断的表数据
恢复场景1 误Truncate表的常规恢复
D公司的业务维护人员由于误将产品数据库当做测试环境库导致错误地TRUNCATE了一张表上的所有数据,DBA尝试恢复但是发觉最近的备份不可用,导致无法从备份中恢复出该数据表上的记录。 此时DBA决定采用PRM来恢复已经被TRUNCATE掉的数据。
由于该环境中 所有数据库文件均是可用且健康的,用户仅需要 字典模式下加载SYSTEM表空间的数据文件以及被TRUNCATED表的数据文件即可,例如:
create table ParnassusData.torderdetail_his1 tablespace users as
select * from parnassusdata.torderdetail_his;
SQL> desc ParnassusData.TORDERDETAIL_HIS
Name Null? Type
----------------------- -------- --------------
SEQ_ID NOT NULL NUMBER(10)
SI_STATUS NUMBER(38)
D_CREATEDATE CHAR(20)
D_UPDATEDATE CHAR(20)
B_ISDELETE CHAR(1)
N_SHOPID NUMBER(10)
N_ORDERID NUMBER(10)
C_ORDERCODE CHAR(20)
N_MEMBERID NUMBER(10)
N_SKUID NUMBER(10)
C_PROMOTION NVARCHAR2(5)
N_AMOUNT NUMBER(7,2)
N_UNITPRICE NUMBER(7,2)
N_UNITSELLINGPRICE NUMBER(7,2)
N_QTY NUMBER(7,2)
N_QTYFREE NUMBER(7,2)
N_POINTSGET NUMBER(7,2)
N_OPERATOR NUMBER(10)
C_TIMESTAMP VARCHAR2(20)
H_SEQID NUMBER(10)
N_RETQTY NUMBER(7,2)
N_QTYPOS NUMBER(7,2)
select count(*) from ParnassusData.TORDERDETAIL_HIS;
COUNT(*)
----------
984359
select bytes/1024/1024 from dba_segments where segment_name='TORDERDETAIL_HIS' and owner='PARNASSUSDATA';
BYTES/1024/1024
---------------
189.71875
SQL> truncate table ParnassusData.TORDERDETAIL_HIS;
Table truncated.
SQL> select count(*) from ParnassusData.TORDERDETAIL_HIS;
COUNT(*)
----------
0
启动PRM ,并选择 Tools => Recovery Wizard
点击Next
在此TRUNCATE场景中并未采用ASM存储,所以仅需要选择 《Dictionary Mode》字典模式即可:
下一步骤 我们要选择几个参数 : 包括Endian 字节序和DB NAME
由于ORACLE数据文件在不同的操作系统平台上采用了不同的Endian字节序格式,字节序和平台对应列表如下:
Solaris[tm] OE (32-bit)
Big
Solaris[tm] OE (64-bit)
Big
Microsoft Windows IA (32-bit)
Little
Linux IA (32-bit)
Little
AIX-Based Systems (64-bit)
Big
HP-UX (64-bit)
Big
HP Tru64 UNIX
Little
HP-UX IA (64-bit)
Big
Linux IA (64-bit)
Little
HP Open VMS
Little
Microsoft Windows IA (64-bit)
Little
IBM zSeries Based Linux
Big
Linux x86 64-bit
Little
Apple Mac OS
Big
Microsoft Windows x86 64-bit
Little
Solaris Operating System (x86)
Little
IBM Power Based Linux
Big
HP IA Open VMS
Little
Solaris Operating System (x86-64)
Little
Apple Mac OS (x86-64)
Little