|
1 ACCESS$
SQL> SELECT * FROM YANGTK.TEST WHERE ID = 123;
ID NAME
---------- ------------------------------
123 ALL_REPCONFLICT
SQL> COMMIT;
至此,已经成功的恢复了数据。
3 使用P_DUMPROWID恢复数据的例子
下面再简单说明一下这个程序包是如何恢复其他数据类型的。
通过查询ORPHAN_KEY_TABLE可以发现,Oracle把索引的值保存在逻辑ROWID中,我这个包实现的其实就是将逻辑ROWID中的值还原为索引键值。下面的例子为了简单起见,通过建立索引组织表,然后使用这个包还原索引组织表的ROWID信息作为参考的例子。
例1:对NUMBER类型、VARCHAR2类型和TIME类型的恢复,对复合索引的恢复。
SQL> create table test_index (id number, name varchar2(30), time date,
2 constraint pk_test_index primary key (id, name, time))
3 organization index;
表已创建。
SQL> insert into test_index select rownum, object_name, created from user_objects;
已创建64行。
SQL> commit;
提交完成。
SQL> col dump format a30
SQL> alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss';
会话已更改。
SQL> select id, p_dumprowid.f_dump_from_rowid(ROWID, 'YANGTK', 'PK_TEST_INDEX') dump
2 from test_index where rownum < 5;
ID DUMP
---------- ------------------------------
1 1
2 2
3 3
4 4
SQL> select name, p_dumprowid.f_dump_from_rowid(ROWID, 'YANGTK', 'PK_TEST_INDEX', 2) dump
2 from test_index where rownum < 5;
NAME DUMP
------------------------------ ------------------------------
AA AA
IND_Q1_ID IND_Q1_ID
IND_Q1_ID IND_Q1_ID
IND_Q1_ID IND_Q1_ID
SQL> select time, p_dumprowid.f_dump_from_rowid(ROWID, 'YANGTK', 'PK_TEST_INDEX', 3) dump
2 from test_index where rownum < 5;
TIME DUMP
------------------- ------------------------------
2004-12-19 02:36:33 2004-12-19 2:36:33
2004-12-18 23:17:56 2004-12-18 23:17:56
2004-12-18 23:17:56 2004-12-18 23:17:56
2004-12-18 23:18:33 2004-12-18 23:18:33
例二:对TIMESTAMP类型的恢复。
SQL> create table test_stamp (time timestamp constraint pk_test_stamp primary key)
2 organization index;
表已创建。
SQL> insert into test_stamp values (systimestamp);
已创建 1 行。
SQL> alter session set nls_timestamp_format = 'yyyy-mm-dd hh24:mi:ss.ff';
会话已更改。
SQL> col dump format a40
SQL> col time format a40
SQL> select time, p_dumprowid.f_dump_from_rowid(rowid, 'YANGTK', 'PK_TEST_STAMP') dump
2 from test_stamp;
TIME DUMP
---------------------------------------- ----------------------------------------
2005-01-13 00:44:27.392000 2005-1-13 0:44:27.392000
上一篇:Oracle如何配置逻辑备用数据库
下一篇:Sql server动态建立数据对象结构
|