Flashback Query and Flashback Table (fast Flashback Query and quick Flashback Table)

Source: Internet
Author: User

Flashback query is a flashback Based on the undo tablespace. The related parameters are as follows:

SQL> show parameter undo

NAME TYPE VALUE
-----------------------------------------------------------------------------
Undo_management string AUTO
Undo_retention integer 900
Undo_tablespace string UNDOTBS1

Undo_management:The undo management method can be automatic auto or manual manul. The default value is auto.

Undo_retention:This parameter indicates that if the space in the undo tablespace is sufficient, the undo data should be retained for at least 900 seconds;

 

 

 

SQL> insert into test01_delete select * from test01 as of timestamp into imestamp-interval '1' minute

Where id not in (select id from test01 );

SQL> create table test01_delete as select * from test01 as of timestamp when imestamp-interval '1' minute

Where id not in (select id from test01 );

 

Use of Flashback Table flash back Table

Like Flashback Query, Flashback Table is based on undo Flashback. You must have the flashback table permission and the row movement function when flashing back a table;

Example:

[Oracle @ b1 ~] $ Export NLS_DATE_FORMAT = "YYYY-MM-DD HH24: MI: SS"

SQL> select to_date (sysdate, 'yyyy-MM-DD HH24: MI: ss') sys_date from dual;

SYS_DATE
-------------------
18:11:39

SQL> select dbms_flashback.get_system_change_number from dual;

GET_SYSTEM_CHANGE_NUMBER
------------------------
1054345

SQL> grant flashback any table to scott;

Grant succeeded.

SQL> conn scott/xyc
Connected.

SQL> select * from xyc_t1;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
-----------------------------------------------------------------------------------------------------------
7698 blake manager 7839 00:00:00 2850 30
7902 ford analyst 7566 00:00:00 8888 20

SQL> delete from xyc_t1;

2 rows deleted.

SQL> commit;

Commit complete.


SQL> flashback table xyc_t1 to scn '123 ';
Flashback table xyc_t1 to scn '20140901'
*
ERROR at line 1:
ORA-08189: cannot flashback the table because row movement is not enabled-the row movement function must be enabled


SQL> alter table xyc_t1 enable row movement;-The row movement function is enabled.

Table altered.

SQL> flashback table xyc_t1 to scn '123 ';

Flashback complete.

SQL> select * from xyc_t1;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
-----------------------------------------------------------------------------------------------------------
7698 blake manager 7839 00:00:00 2850 30
7902 ford analyst 7566 00:00:00 8888 20

SQL> flashback table xyc_t1 to timestamp to_timestamp ('2017-10-06 18:10:51 ', 'yyyy-MM-DD HH24: MI: ss ');

Flashback complete.

SQL> select * from xyc_t1;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
-----------------------------------------------------------------------------------------------------------
7698 blake manager 7839 00:00:00 2850 30
7902 ford analyst 7566 00:00:00 8888 20

SQL>

 

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.