日期: 2014-01-20

Flashback Transaction in Oracle 11g

Flashback transaction 可以回退已经提交的事务,并且可以选择是否回退和该事务有关联的数据

启用flashback transaction需要开启数据库的supplemental log(minimal 和 primary)

Sqlplus / as sysdba

SQL>ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

SQL>ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;

 

创建测试表

CONN test /test

CREATE TABLE test_tab (

id NUMBER,

description VARCHAR2(50),

CONSTRAINT test_tab_pk PRIMARY KEY (id)

);

 

INSERT INTO test_tab (id, description) VALUES (1, ‘One’);

COMMIT;

INSERT INTO test_tab (id, description) VALUES (2, ‘Two’);

COMMIT;

UPDATE test_tab SET description = ‘One2Three’ WHERE id = 1;

COMMIT;

UPDATE test_tab SET description = ‘Tow2Four’ WHERE id = 2;

COMMIT;

DELETE FROM test_tab WHERE id = 1;

COMMIT;

 

select * from test_tab

    ID DESCRIPTION

———- ——————–

     2 Field

阅读详细 »