使用fy_recover_data恢复truncate表的数据

发布时间:2020-08-09 22:12:15 作者:abstractcyj
来源:ITPUB博客 阅读:268

1.       @/home/oracle/FY_Recover_Data.SQL
创建需要的package
[oracle@localhost oradata]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Thu May 17 00:43:59 2018

 

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> @/home/oracle/FY_Recover_Data.SQL

Package created.

Package body created.

2.       创建测试数据:
create table scott.test_emp tablespace users as select * from scott.emp;
truncate table scott.test_emp

3.       执行脚本:
注意路径:“/u01/app/oracle/oradata/orcl/”最后的”/”不能缺少
DECLARE

  tgtowner VARCHAR2(30);

  tgttable VARCHAR2(30);

  datapath VARCHAR2(4000);

  datadir  VARCHAR2(30);

  rects    VARCHAR2(30);

  recfile  VARCHAR2(30);

  rstts    VARCHAR2(30);

  rstfile  VARCHAR2(30);

  blksz    NUMBER;

  rectab   VARCHAR2(30);

  rsttab   VARCHAR2(30);

  copyfile VARCHAR2(30);

BEGIN

  tgtowner := 'SCOTT'; --table owner

  tgttable := 'TEST_EMP'; --table name

  datapath := '/u01/app/oracle/oradata/orcl/'; --必须和test.t1表所在的数据文件的目录相同

  datadir  := 'FY_DATA_DIR'; --oracle中目录的名字,可以修改

  fy_recover_data.prepare_files(tgtowner,

                                tgttable,

                                datapath,

                                datadir,

                                rects,

                                recfile,

                                rstts,

                                rstfile,

                                blksz);

  fy_recover_data.fill_blocks(tgtowner,

                              tgttable,

                              datadir,

                              rects,

                              recfile,

                              rstts,

                              8,

                              tgtowner,

                              tgtowner,

                              rectab,

                              rsttab,

                              copyfile);

  fy_recover_data.recover_table(tgtowner,

                                tgttable,

                                tgtowner,

                                rectab,

                                tgtowner,

                                rsttab,

                                datadir,

                                datadir,

                                recfile,

                                datadir,

                                copyfile,

                                blksz);

 

END;

执行完成之后,会看到scott用户下多了表:
SQL> select table_name, tablespace_name from dba_tables where owner = 'SCOTT';

 

TABLE_NAME                             TABLESPACE_NAME

------------------------------ ------------------------------

DEPT                                             USERS

EMP                                              USERS

BONUS                                         USERS

SALGRADE                                   USERS

TEST_EMP$                                 FY_REC_DATA

TEST_EMP$$                              FY_RST_DATA

TEST_EMP                                   USERS

 

7 rows selected.

将TEST_EMP$$插回TEST_EMP

使用fy_recover_data恢复truncate表的数据FY_Recover_Data.sql


参考:http://www.hellodba.com/reader.php?ID=191&lang=cn

推荐阅读:
  1. Oracle数据库truncate table后恢复原来数据
  2. Oracle 表和表数据恢复

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

data fy recover

上一篇:使用SRAM如何节省芯片面积

下一篇:mysql之 Percona XtraDB Cluster集群线程模型

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》