Use of the Oracle 11g Recycle Bin (recyclebin)

Source: Internet
Author: User

Flashback is based on the content in the undo segment. Therefore, due to the undo_retenton parameter, to use the flashback feature, you must enable automatic tablespace revocation.

Oracle flashback data archive (FDA) is a new feature in Oracle11g. By storing changed data to another created flashback archive ), different from undo, you can set a separate storage policy so that it can return to the old data before the specified time without affecting the undo policy. In Oracle 11g, The recyclebin parameter changes slightly.

This supported parameter was introduced in Oracle 10.2.0

Version

Parameter Name

Data Type

Session Modifiable

System Modifiable

10.2.0

Recyclebin

String

TRUE

IMMEDIATE

11.1.0

Recyclebin

String

TRUE

DEFERRED

We can see this change description in the document. In the 11g, this parameter can still be modified immediately in the session and affect the current session, but if it is modified at the system level, the deferred parameter must be added, which does not affect the currently connected sesion, but the session of the new connection will be affected.

Flashback does not support sys users. Objects in the system tablespace cannot be obtained from the recycle bin. Therefore, show recyclebin is empty when using sys or system user logon.

To start a database flash:

1. Enable archive mode: alter database archivelog;

2. Configure the flash back area: alter system set db_recovery_file_dest = '/../'

3. Configure the flash back retention time. The default value is 1440 minutes: alter system set db_flashback_retention_target = '123 ';

4. Start the flash back database: shutdown immediate; startup mount

Alter database flashback on/off;

5. Perform the flash back operation: shutdown immediate; startup mount;

Flashback database to timestamp to_date ('2017-02-03 ', 'yyyy-mm-dd hh24: mi: ss ');

Or: flashback database to scn 2323534;

Alter database open ready only; check whether the flash time is the required data. If not, you can continue to modify it.

After the check, shutdown immediate; startup mount; alter database open resetlogs; resetlogs synchronizes the scn # In the control file with the scn # in the data file to eliminate the time interval.

In the V $ flashback_database_log view, you can view the space occupied by the flash log, the first scn to be flashed back, and the first time point to be flashed back.

7. view the recycle bin: show recyclebin; or select * from sys. recyclebin $ to check all the recycle bins.

8. Restore the deleted table: flashback table t_name to before drop.

The table name is the same as the current table name. You need to rename it to flash back.

Flashback table t_name to before drop rename to t_new;

9. flash back to the specified table

View the table structure: desc "BIN $ q1_yuhuvothgqab/AQAQ3w ==0 0 ";

View table records: select count (*) from "BIN $ q1_yuhuvothgqab/AQAQ3w ==$ 0 ";

Restore the installation table name: flashback table "BIN $ q1_yuhuvothgqab/AQAQ3w = $0" to before drop;

Delete directly from the recycle bin: drop table t purge; drop user cascade; drop tablespace users including contents;

Clear the recycle bin: purge index idx_1; purge user_recyclebin; purge dba_recyclebin;

When db_recovery_file_dest is set to null, you can also cancel the flash back area. If flashback database is enabled, this method cannot be canceled.

View the current scn: select current_scn from v $ database;

Check which objects can be stored in the Flash recovery zone:

SQL> select file_type from v $ flash_recovery_area_usage;

 

FILE_TYPE

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

CONTROL FILE

REDO LOG

ARCHIVED LOG

BACKUP PIECE

IMAGE COPY

FLASHBACK LOG

FOREIGN ARCHIVED LOG

 

7 rows selected.

 

View the space usage in the Flash recovery zone:

SQL> select * from v $ flash_recovery_area_usage;

 

FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE

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

NUMBER_OF_FILES

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

Control file 0 0

0

 

Redo log 0 0

0

 

Archived log 0 0

0

 

 

FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE

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

NUMBER_OF_FILES

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

Backup piece 0 0

0

 

Image copy 0 0

0

 

Flashback log 0 0

0

 

 

FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE

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

NUMBER_OF_FILES

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

Foreign archived log 0 0

0

 

 

7 rows selected.

Computing space occupied by flash recovery area:

 

SQL> select sum (percent_space_used) * 3/100 from v $ flash_recovery_area_usage;

 

SUM (PERCENT_SPACE_USED) * 3/100

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

0

If the flash recovery area space is insufficient, the database cannot be opened or the hang is occupied.

Alter system set db_recovery_file_dest_size = 3G scope = spfiel;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.