1.
表查詢閃回
create table xcp as (select * from b_za_bzdzkxx);
select * from xcp;
select count(1) from xcp;--22001
select count(1) from xcp t where t.dzbh like '510521%';--7011
delete from xcp t where t.dzbh like '510521%';
select count(1) from xcp;--14990
--查找指定時間點前的數據
select count(1) from xcp as of timestamp to_timestamp('2011-12-23 10:49:30','yyyy-MM-dd hh24:mi:ss');--22001
select * from xcp for update;--添加一條記錄
select count(1) from xcp;--14991
--恢復指定時間點的前delete數據(將刪除恢復時間點后面的數據)
alter table xcp enable row movement;--啟動的行移動功能
flashback table xcp to timestamp to_timestamp('2011-12-23 10:49:30','yyyy-MM-dd hh24:mi:ss');
select count(1) from xcp;--22001
--恢復指定時間點的前delete數據,并保留恢復時間點后面的數據
create table xcp2 as (select * from xcp t where t.createdtime>to_timestamp('2011-12-23 10:49:30','yyyy-MM-dd hh24:mi:ss'));
select * from xcp2;--臨時表
alter table xcp enable row movement;--啟動的行移動功能
flashback table xcp to timestamp to_timestamp('2011-12-23 10:49:30,'yyyy-MM-dd hh24:mi:ss');
select count(1) from xcp;--22001
insert into xcp select * from xcp2 --將臨時表的數據再插入到源表
select count(1) from xcp;--22002
2.刪除閃回[10g+]
刪除閃回為刪除oracle 10G提供了一個數據庫安全機制,當用戶刪除一個表時,oracle 10G會將該表放到回收站中,回收站中的對象一直會保留,直到用戶決定永久刪除它們或出現表空間的空間不足時才會被刪除。回收站是一個虛擬容器,用于存儲所有被刪除的對象。數據字典user_tables中的列dropped表示被刪除的表,查詢方法如下:
select table_name,dropped from user_tables;
--設置數據庫是否啟用回收站
alert session set recyclebin = off;
--查詢回收站對象
drop table xcp;
select count(1) from xcp;--0
--恢復drop的表
flashback table xcp to before drop;
select count(1) from xcp;--22001
如果不知道原表名,可以直接使用回收站中的名稱進行閃回..
--真正刪除一個表,而不進入回收站,可以在刪除表時增加purge選項
drop table xcp1 purge;
--也可以從回收站永久性刪除表
purge table xcp1;
--刪除當前用戶回收站
purge recyclebin
--刪除全體用戶在回收站的資源
purge dba_resyclebin
3.數據庫閃口 [10g+]
使用數據庫閃回功能,可以使數據庫回到過去某一狀態,語法如下:
sql: alter database flashback on;
sql: flashback database to scn 46963;
sql: flashback database to timestamp to_timestamp('2007-2-12 12:00:00','yyyy-MM-dd hh24:mi:ss');
注:表結構修改后不能直接恢復
http://blog.csdn.net/colin_liu2009/article/details/6906548
http://www.xifenfei.com/2012/06/%E5%88%A9%E7%94%A8flashback-database%E5%AE%9E%E7%8E%B0%E9%83%A8%E5%88%86%E5%AF%B9%E8%B1%A1%E5%9B%9E%E6%BB%9A.html
create table xcp as (select * from b_za_bzdzkxx);
select * from xcp;
select count(1) from xcp;--22001
select count(1) from xcp t where t.dzbh like '510521%';--7011
delete from xcp t where t.dzbh like '510521%';
select count(1) from xcp;--14990
--查找指定時間點前的數據
select count(1) from xcp as of timestamp to_timestamp('2011-12-23 10:49:30','yyyy-MM-dd hh24:mi:ss');--22001
select * from xcp for update;--添加一條記錄
select count(1) from xcp;--14991
--恢復指定時間點的前delete數據(將刪除恢復時間點后面的數據)
alter table xcp enable row movement;--啟動的行移動功能
flashback table xcp to timestamp to_timestamp('2011-12-23 10:49:30','yyyy-MM-dd hh24:mi:ss');
select count(1) from xcp;--22001
--恢復指定時間點的前delete數據,并保留恢復時間點后面的數據
create table xcp2 as (select * from xcp t where t.createdtime>to_timestamp('2011-12-23 10:49:30','yyyy-MM-dd hh24:mi:ss'));
select * from xcp2;--臨時表
alter table xcp enable row movement;--啟動的行移動功能
flashback table xcp to timestamp to_timestamp('2011-12-23 10:49:30,'yyyy-MM-dd hh24:mi:ss');
select count(1) from xcp;--22001
insert into xcp select * from xcp2 --將臨時表的數據再插入到源表
select count(1) from xcp;--22002
2.刪除閃回[10g+]
刪除閃回為刪除oracle 10G提供了一個數據庫安全機制,當用戶刪除一個表時,oracle 10G會將該表放到回收站中,回收站中的對象一直會保留,直到用戶決定永久刪除它們或出現表空間的空間不足時才會被刪除。回收站是一個虛擬容器,用于存儲所有被刪除的對象。數據字典user_tables中的列dropped表示被刪除的表,查詢方法如下:
select table_name,dropped from user_tables;
--設置數據庫是否啟用回收站
alert session set recyclebin = off;
--查詢回收站對象
select * from recyclebin;
select * from user_recyclebin;
select * from dba_recyclebin;
drop table xcp;
select count(1) from xcp;--0
--恢復drop的表
flashback table xcp to before drop;
select count(1) from xcp;--22001
如果不知道原表名,可以直接使用回收站中的名稱進行閃回..
flashback table "BIN$JiXyAUO4R+u3qNVfQK/Kiw==$0" to before drop;
在回收的同時可以修改表名flashback table "
BIN$JiXyAUO4R+u3qNVfQK/Kiw==$0" to before drop rename to xcp1;
--真正刪除一個表,而不進入回收站,可以在刪除表時增加purge選項
drop table xcp1 purge;
--也可以從回收站永久性刪除表
purge table xcp1;
--刪除當前用戶回收站
purge recyclebin
--刪除全體用戶在回收站的資源
purge dba_resyclebin
3.數據庫閃口 [10g+]
使用數據庫閃回功能,可以使數據庫回到過去某一狀態,語法如下:
sql: alter database flashback on;
sql: flashback database to scn 46963;
sql: flashback database to timestamp to_timestamp('2007-2-12 12:00:00','yyyy-MM-dd hh24:mi:ss');
注:表結構修改后不能直接恢復
http://blog.csdn.net/colin_liu2009/article/details/6906548
http://www.xifenfei.com/2012/06/%E5%88%A9%E7%94%A8flashback-database%E5%AE%9E%E7%8E%B0%E9%83%A8%E5%88%86%E5%AF%B9%E8%B1%A1%E5%9B%9E%E6%BB%9A.html
名稱: ?4C.ESL | .↗Evon
口號: 遇到新問題?先要尋找一個方案乄而不是創造一個方案こ
mail: 聯系我