Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Using fy_recover_data to recover the data of truncate table

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. @ / home/oracle/FY_Recover_Data.SQL

Create the required 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.

two。 Create test data:

Create table scott.test_emp tablespace users as select * from scott.emp

Truncate table scott.test_emp

3. Execute the script:

Note the path: the last "/" of "/ u01/app/oracle/oradata/orcl/" cannot be missing.

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:-- must be the same as the directory of the data file where the test.t1 table is located

Datadir: = 'FY_DATA_DIR';-- the name of the directory in oracle, which can be modified

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

eight,

Tgtowner

Tgtowner

Rectab

Rsttab

Copyfile)

Fy_recover_data.recover_table (tgtowner

Tgttable

Tgtowner

Rectab

Tgtowner

Rsttab

Datadir

Datadir

Recfile

Datadir

Copyfile

Blksz)

END

After the execution is complete, you will see that the scott user has added more tables:

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.

Insert TEST_EMP$$ back into TEST_EMP

FY_Recover_Data.sql

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report