2009년 4월 30일 목요일

10g Flashback Version Query

SQL> create table rates (
2 currency varchar2(4),
3 rate number(15,10)
4 );

테이블이 생성되었습니다.

SQL> insert into rates values ('EURO',1.1012);

1 개의 행이 만들어졌습니다.

SQL> commit;

커밋이 완료되었습니다.

SQL> update rates set rate = 1.1014;

1 행이 갱신되었습니다.

SQL> commit;

커밋이 완료되었습니다.

SQL> update rates set rate = 1.1013;

1 행이 갱신되었습니다.

SQL> commit;

커밋이 완료되었습니다.

SQL> delete rates;

1 행이 삭제되었습니다.

SQL> commit;

커밋이 완료되었습니다.

SQL> insert into rates values ('EURO',1.1016);

1 개의 행이 만들어졌습니다.

SQL> commit;

커밋이 완료되었습니다.

SQL> update rates set rate = 1.1011;

1 행이 갱신되었습니다.

SQL> commit;

커밋이 완료되었습니다.

SQL> select * from rates;

CURR RATE
---- ----------
EURO 1.1011

SQL> col VERSIONS_STARTTIMe for a18
SQL> col VERSIONS_ENDTIME for a18

SQL> select versions_starttime, versions_endtime, versions_xid, versions_operation, rate
2 from rates versions between timestamp minvalue and maxvalue
3* order by VERSIONS_STARTTIME ;

VERSIONS_STARTTIME VERSIONS_ENDTIME VERSIONS_XID V RATE
------------------ ------------------ ---------------- - ----------
09/04/30 21:55:42 09/04/30 21:56:06 0009000F000B0C4C I 1.1012
09/04/30 21:56:06 09/04/30 21:56:12 00090024000B0B89 U 1.1014
09/04/30 21:56:12 09/04/30 21:56:30 0008000A000C0FCD U 1.1013
09/04/30 21:56:30 00080020000C11ED D 1.1013
09/04/30 21:56:42 09/04/30 21:56:58 00080018000C0D63 I 1.1016
09/04/30 21:56:58 000400090009A1B8 U 1.1011

6 개의 행이 선택되었습니다.

SQL> conn / as sysdba
연결되었습니다.
SQL> grant select any transaction to scott;

권한이 부여되었습니다.

SQL> conn scott/*****

SQL> select undo_sql
2 from flashback_transaction_query
3 where xid='0009000F000B0C4C';

-----------------------------------------------------------------------
insertinto "ANANDA"."RATES"("CURRENCY","RATE")values ('EURO','1.1013');

SQL> select rate, versions_starttime, versions_endtime
2 from rates versions between timestamp to_date(...) and to_date(...)
3* order by VERSIONS_STARTTIME ;

RATE VERSIONS_STARTTIME VERSIONS_ENDTIME
---------- ---------------------- ----------------------
1.1011

댓글 없음:

댓글 쓰기