溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Oracle Drop表如何進(jìn)行purge恢復(fù)ODU

發(fā)布時(shí)間:2021-11-12 15:41:02 來源:億速云 閱讀:401 作者:柒染 欄目:關(guān)系型數(shù)據(jù)庫(kù)

這篇文章給大家介紹Oracle Drop表如何進(jìn)行purge恢復(fù)ODU,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

Oracle Drop表(purge)恢復(fù)(ODU)

通過ODU恢復(fù)drop掉的表(purge)基本步驟如下

1:offline表所在表空間;

2:通過logminer挖出被drop表對(duì)應(yīng)object_id;

3:使用ODU工具將表數(shù)據(jù)抽到文件中;

4:使用sqlldr將數(shù)據(jù)加載到數(shù)據(jù)庫(kù);

5:驗(yàn)證;

一:主備測(cè)試數(shù)據(jù)              

1 創(chuàng)建測(cè)試表odu_test

create table odu_test (a number,b varchar2(10),c nvarchar2(30),d varchar2(20),e date,f timestamp,g binary_float,h binary_double);

2 插入測(cè)試數(shù)據(jù)

insert into odu_test

  select rownum,

         lpad('x', 10),

         'NC測(cè)試' || rownum,

         'ZHS測(cè)試' || rownum,

         sysdate + dbms_random.value(0, 100),

         systimestamp + dbms_random.value(0, 100),

         rownum + dbms_random.value(0, 10000),

         rownum + dbms_random.value(0, 10000)

    from dba_objects

   where rownum <= 10000;

commit;

3 備份并刪除表odu_test,模擬誤刪除

create table odu1 as select * from odu_test;

drop table odu_test purge;

二:恢復(fù)

1 offline表所在表空間

alter tablespace users offline;

2 使用logminer來查找被drop表的object_id

select group#,status from v$log;

select member from v$logfile where group#=1;

SQL> exec sys.dbms_logmnr.start_logmnr(options=>sys.dbms_logmnr.dict_from_online_catalog);

SQL> select scn,timestamp,sql_redo from v$logmnr_contents where operation='DDL' and sql_redo like '%odu_test%' order by 2 ;

......

    990001 2017/12/27  drop table odu_test purge;

SQL> select scn,timestamp,sql_redo from v$logmnr_contents where timestamp=to_date('2017-12-27','yyyy-mm-dd') order by 1;

SQL> create table logmnr_1 as (select * from  v$logmnr_contents;

SQL> exec sys.dbms_logmnr.end_logmnr;

select *from sys.logmnr_1 where scn='990001';  ---DATA_OB# 87270

select * from sys.logmnr_1 where /*operation='DDL' and*/ LOWER(sql_redo) like '%odu_test%' order by 2 ;

/*

delete from "SYS"."OBJ$" where "OBJ#" = '87270' and "DATAOBJ#" = '87270' and "OWNER#" = '84' and "NAME" = 'ODU_TEST' and "NAMESPACE" = '1' and "SUBNAME" IS NULL and "TYPE#" = '2' and "CTIME" = TO_DATE('27-12月-17', 'DD-MON-RR') and "MTIME" = TO_DATE('27-12月-17', 'DD-MON-RR') and "STIME" = TO_DATE('27-12月-17', 'DD-MON-RR') and "STATUS" = '1' and "REMOTEOWNER" IS NULL and "LINKNAME" IS NULL and "FLAGS" = '0' and "OID$" IS NULL and "SPARE1" = '6' and "SPARE2" = '1' and "SPARE3" = '84' and "SPARE4" IS NULL and "SPARE5" IS NULL and "SPARE6" IS NULL and ROWID = 'AAAAASAABAAAVKkABB';

*/

3 修改原control.txt文件

select d.TS#        ts,

       d.FILE#      fno,

       d.FILE#      fno,

       d.NAME       filename,

       d.BLOCK_SIZE block_size

  from v$datafile d

 order by ts;

0    1    1    D:\APP\ADMINISTRATOR\ORADATA\CJC\SYSTEM01.DBF  8192

1    2    2    D:\APP\ADMINISTRATOR\ORADATA\CJC\SYSAUX01.DBF  8192

2    3    3    D:\APP\ADMINISTRATOR\ORADATA\CJC\UNDOTBS01.DBF 8192

4    4    4    D:\APP\ADMINISTRATOR\ORADATA\CJC\USERS01.DBF   8192

---control.txt

Oracle Drop表如何進(jìn)行purge恢復(fù)ODU

4 登錄odu

Oracle Drop表如何進(jìn)行purge恢復(fù)ODU

Oracle Drop表如何進(jìn)行purge恢復(fù)ODU

5 掃描數(shù)據(jù)

Oracle Drop表如何進(jìn)行purge恢復(fù)ODU

---企業(yè)版ODU需要授權(quán)

Oracle Drop表如何進(jìn)行purge恢復(fù)ODU

---本次實(shí)驗(yàn)使用測(cè)試版ODU

6 恢復(fù)表

Oracle Drop表如何進(jìn)行purge恢復(fù)ODU

Oracle Drop表如何進(jìn)行purge恢復(fù)ODU

......

Oracle Drop表如何進(jìn)行purge恢復(fù)ODU

生成創(chuàng)建表的語(yǔ)句和控制文件

Oracle Drop表如何進(jìn)行purge恢復(fù)ODU

這個(gè)命令生成了如下文件

ODU_0000087270.ctl和ODU_0000087270.sql

CREATE TABLE "ODU_0000087270"

(

    "C0001" NUMBER ,

    "C0002" VARCHAR2(4000) ,

    "C0003" NVARCHAR2(2000) ,

    "C0004" VARCHAR2(4000) ,

    "C0005" DATE ,

    "C0006" DATE ,

    "C0007" BINARY_FLOAT ,

    "C0008" BINARY_DOUBLE

);

7 online表空間

alter tablespace users online;

8 通過sqlldr加載數(shù)據(jù)

Oracle Drop表如何進(jìn)行purge恢復(fù)ODU

9 驗(yàn)證數(shù)據(jù)

select count(*) from ODU_0000087270;  ---10000

查看恢復(fù)后表數(shù)據(jù)

select * from ODU_0000087270;

Oracle Drop表如何進(jìn)行purge恢復(fù)ODU

......

查看備份表數(shù)據(jù)

Oracle Drop表如何進(jìn)行purge恢復(fù)ODU

關(guān)于Oracle Drop表如何進(jìn)行purge恢復(fù)ODU就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI