Oracle10g New Feature -- 3.Flashback Table
Oracle 10g引入了recyclebin,類似於windows的回收站,使你能夠很方便的恢復誤刪的表。
但是對於truncate table,好像還是沒有一種快速的恢復方法
[@more@]1. Flashback TableExample:SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
------------------------ --------- -------------------
FLASH TABLE
IDX1_FLASH INDEX
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
FLASH TABLE
SQL> drop table flash;
Table dropped.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BIN$NHMSE3qoQlmhlzmeiDOQpw==$0 TABLE
SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
--------------------------------------------------------------- -------------------
BIN$NHMSE3qoQlmhlzmeiDOQpw==$0 TABLE
BIN$fJd3Ze8AQJODogj64ZE+7A==$0 INDEX
dropped table FLASH, instead of completely disappearing, was renamed to a system-defined name. It stays in the same tablespace, with the same structure as that of the original table.
The indexes or triggers defined on the table, they are renamed too, using the same naming convention used by the table
The table and its associated objects are placed in a logical container known as the "recycle bin,"
SQL> show recyclebin
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
-------------------------- ------------------------------------------- ------------------- -------------------
FLASH BIN$NHMSE3qoQlmhlzmeiDOQpw==$0 TABLE 2004-09-08:16:56:11
ORIGINAL NAME: the original name of the table
RECYCLEBIN NAME: the new name in the recycle bin
reinstate the table
SQL> flashback table flash to before drop;
Flashback complete.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
FLASH TABLE
SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
-------------------------------------------------- -------------------
FLASH TABLE
BIN$fJd3Ze8AQJODogj64ZE+7A==$0 INDEX
SQL>alter index “BIN$fJd3Ze8AQJODogj64ZE+7A==$0” rename to idx1_flash;
SQL> show recyclebin
“EMPTY”
The un-drop feature brings the table back to its original name, but not the associated objects like indexes and triggers, which are left with the recycled names.
To free the space
SQL>purge recyclebin
drop the table completely
SQL> drop table flash purge;
Table dropped.
SQL> show recyclebin
“EMPTY”
Managing the Recycle Binpurge the specific table named TEST from the recycle bin after its dropSQL>PURGE TABLE TEST;
or using its recycle bin name:
SQL>PURGE TABLE "BIN$04LhcpndanfgMAAAAAANPw==$0";
permanently drop an index from the recycle binSQL> drop table flash;
Table dropped.
SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
--------------------------------------------------------- -------------------
BIN$RGaBIxRdSW65NUWeQ6NOAg==$0 TABLE
BIN$uix7J5C2TomXdYKjdzGXOQ==$0 INDEX
SQL> purge index idx1_flash;
Index purged.
SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
--------------------------------------------------------- -------------------
BIN$RGaBIxRdSW65NUWeQ6NOAg==$0 TABLE
purge all the objects in recycle bin in a tablespace USERSPURGE TABLESPACE USERS;
purge only the recycle bin for a particular user in that tablespacePURGE TABLESPACE USERS USER SCOTT;
A user such as SCOTT would clear his own recycle bin with
PURGE RECYCLEBIN;
You as a DBA can purge all the objects in any tablespace using
PURGE DBA_RECYCLEBIN;
Table Versions and Flashback
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (1);
COMMIT;
DROP TABLE TEST;
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (2);
COMMIT;
DROP TABLE TEST;
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (3);
COMMIT;
DROP TABLE TEST;
At this point, if you were to flash-back the table TEST, the third version of the table is retrieved, not the first. So the column COL1 will have the value 3, not 1.
you can also retrieve the other versions of the dropped table
- Use the rename option:
SQL>FLASHBACK TABLE TEST TO BEFORE DROP RENAME TO TEST2;
SQL>FLASHBACK TABLE TEST TO BEFORE DROP RENAME TO TEST1;
- Use the specific recycle-bin names of the table to restore. To do that, first identify the table's recycle bin names and then issue:
SQL>FLASHBACK TABLE "BIN$04LhcpnoanfgMAAAAAANPw==$0" TO BEFORE DROP RENAME TO TEST2;
SQL>FLASHBACK TABLE "BIN$04LhcpnqanfgMAAAAAANPw==$0" TO BEFORE DROP RENAME TO TEST1;
SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
------------------------ --------- -------------------
FLASH TABLE
IDX1_FLASH INDEX
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
FLASH TABLE
SQL> drop table flash;
Table dropped.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BIN$NHMSE3qoQlmhlzmeiDOQpw==$0 TABLE
SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
--------------------------------------------------------------- -------------------
BIN$NHMSE3qoQlmhlzmeiDOQpw==$0 TABLE
BIN$fJd3Ze8AQJODogj64ZE+7A==$0 INDEX
dropped table FLASH, instead of completely disappearing, was renamed to a system-defined name. It stays in the same tablespace, with the same structure as that of the original table.
The indexes or triggers defined on the table, they are renamed too, using the same naming convention used by the table
The table and its associated objects are placed in a logical container known as the "recycle bin,"
SQL> show recyclebin
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
-------------------------- ------------------------------------------- ------------------- -------------------
FLASH BIN$NHMSE3qoQlmhlzmeiDOQpw==$0 TABLE 2004-09-08:16:56:11
ORIGINAL NAME: the original name of the table
RECYCLEBIN NAME: the new name in the recycle bin
reinstate the table
SQL> flashback table flash to before drop;
Flashback complete.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
FLASH TABLE
SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
-------------------------------------------------- -------------------
FLASH TABLE
BIN$fJd3Ze8AQJODogj64ZE+7A==$0 INDEX
SQL>alter index “BIN$fJd3Ze8AQJODogj64ZE+7A==$0” rename to idx1_flash;
SQL> show recyclebin
“EMPTY”
The un-drop feature brings the table back to its original name, but not the associated objects like indexes and triggers, which are left with the recycled names.
To free the space
SQL>purge recyclebin
drop the table completely
SQL> drop table flash purge;
Table dropped.
SQL> show recyclebin
“EMPTY”
Managing the Recycle Binpurge the specific table named TEST from the recycle bin after its dropSQL>PURGE TABLE TEST;
or using its recycle bin name:
SQL>PURGE TABLE "BIN$04LhcpndanfgMAAAAAANPw==$0";
permanently drop an index from the recycle binSQL> drop table flash;
Table dropped.
SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
--------------------------------------------------------- -------------------
BIN$RGaBIxRdSW65NUWeQ6NOAg==$0 TABLE
BIN$uix7J5C2TomXdYKjdzGXOQ==$0 INDEX
SQL> purge index idx1_flash;
Index purged.
SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
--------------------------------------------------------- -------------------
BIN$RGaBIxRdSW65NUWeQ6NOAg==$0 TABLE
purge all the objects in recycle bin in a tablespace USERSPURGE TABLESPACE USERS;
purge only the recycle bin for a particular user in that tablespacePURGE TABLESPACE USERS USER SCOTT;
A user such as SCOTT would clear his own recycle bin with
PURGE RECYCLEBIN;
You as a DBA can purge all the objects in any tablespace using
PURGE DBA_RECYCLEBIN;
Table Versions and Flashback
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (1);
COMMIT;
DROP TABLE TEST;
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (2);
COMMIT;
DROP TABLE TEST;
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (3);
COMMIT;
DROP TABLE TEST;
At this point, if you were to flash-back the table TEST, the third version of the table is retrieved, not the first. So the column COL1 will have the value 3, not 1.
you can also retrieve the other versions of the dropped table
- Use the rename option:
SQL>FLASHBACK TABLE TEST TO BEFORE DROP RENAME TO TEST2;
SQL>FLASHBACK TABLE TEST TO BEFORE DROP RENAME TO TEST1;
- Use the specific recycle-bin names of the table to restore. To do that, first identify the table's recycle bin names and then issue:
SQL>FLASHBACK TABLE "BIN$04LhcpnoanfgMAAAAAANPw==$0" TO BEFORE DROP RENAME TO TEST2;
SQL>FLASHBACK TABLE "BIN$04LhcpnqanfgMAAAAAANPw==$0" TO BEFORE DROP RENAME TO TEST1;
purge the specific table named TEST from the recycle bin after its dropSQL>PURGE TABLE TEST;
or using its recycle bin name:
SQL>PURGE TABLE "BIN$04LhcpndanfgMAAAAAANPw==$0";
permanently drop an index from the recycle binSQL> drop table flash;
Table dropped.
SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
--------------------------------------------------------- -------------------
BIN$RGaBIxRdSW65NUWeQ6NOAg==$0 TABLE
BIN$uix7J5C2TomXdYKjdzGXOQ==$0 INDEX
SQL> purge index idx1_flash;
Index purged.
SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
--------------------------------------------------------- -------------------
BIN$RGaBIxRdSW65NUWeQ6NOAg==$0 TABLE
purge all the objects in recycle bin in a tablespace USERSPURGE TABLESPACE USERS;
purge only the recycle bin for a particular user in that tablespacePURGE TABLESPACE USERS USER SCOTT;
A user such as SCOTT would clear his own recycle bin with
PURGE RECYCLEBIN;
You as a DBA can purge all the objects in any tablespace using
PURGE DBA_RECYCLEBIN;
Table Versions and Flashback
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (1);
COMMIT;
DROP TABLE TEST;
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (2);
COMMIT;
DROP TABLE TEST;
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (3);
COMMIT;
DROP TABLE TEST;
At this point, if you were to flash-back the table TEST, the third version of the table is retrieved, not the first. So the column COL1 will have the value 3, not 1.
you can also retrieve the other versions of the dropped table
- Use the rename option:
SQL>FLASHBACK TABLE TEST TO BEFORE DROP RENAME TO TEST2;
SQL>FLASHBACK TABLE TEST TO BEFORE DROP RENAME TO TEST1;
- Use the specific recycle-bin names of the table to restore. To do that, first identify the table's recycle bin names and then issue:
SQL>FLASHBACK TABLE "BIN$04LhcpnoanfgMAAAAAANPw==$0" TO BEFORE DROP RENAME TO TEST2;
SQL>FLASHBACK TABLE "BIN$04LhcpnqanfgMAAAAAANPw==$0" TO BEFORE DROP RENAME TO TEST1;
SQL> drop table flash;
Table dropped.
SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
--------------------------------------------------------- -------------------
BIN$RGaBIxRdSW65NUWeQ6NOAg==$0 TABLE
BIN$uix7J5C2TomXdYKjdzGXOQ==$0 INDEX
SQL> purge index idx1_flash;
Index purged.
SQL>select object_name,object_type from user_objects
OBJECT_NAME OBJECT_TYPE
--------------------------------------------------------- -------------------
BIN$RGaBIxRdSW65NUWeQ6NOAg==$0 TABLE
purge all the objects in recycle bin in a tablespace USERSPURGE TABLESPACE USERS;
purge only the recycle bin for a particular user in that tablespacePURGE TABLESPACE USERS USER SCOTT;
A user such as SCOTT would clear his own recycle bin with
PURGE RECYCLEBIN;
You as a DBA can purge all the objects in any tablespace using
PURGE DBA_RECYCLEBIN;
Table Versions and Flashback
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (1);
COMMIT;
DROP TABLE TEST;
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (2);
COMMIT;
DROP TABLE TEST;
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (3);
COMMIT;
DROP TABLE TEST;
At this point, if you were to flash-back the table TEST, the third version of the table is retrieved, not the first. So the column COL1 will have the value 3, not 1.
you can also retrieve the other versions of the dropped table
- Use the rename option:
SQL>FLASHBACK TABLE TEST TO BEFORE DROP RENAME TO TEST2;
SQL>FLASHBACK TABLE TEST TO BEFORE DROP RENAME TO TEST1;
- Use the specific recycle-bin names of the table to restore. To do that, first identify the table's recycle bin names and then issue:
SQL>FLASHBACK TABLE "BIN$04LhcpnoanfgMAAAAAANPw==$0" TO BEFORE DROP RENAME TO TEST2;
SQL>FLASHBACK TABLE "BIN$04LhcpnqanfgMAAAAAANPw==$0" TO BEFORE DROP RENAME TO TEST1;
PURGE TABLESPACE USERS USER SCOTT;
A user such as SCOTT would clear his own recycle bin with
PURGE RECYCLEBIN;
You as a DBA can purge all the objects in any tablespace using
PURGE DBA_RECYCLEBIN;
Table Versions and Flashback
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (1);
COMMIT;
DROP TABLE TEST;
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (2);
COMMIT;
DROP TABLE TEST;
CREATE TABLE TEST (COL1 NUMBER);
INSERT INTO TEST VALUES (3);
COMMIT;
DROP TABLE TEST;
At this point, if you were to flash-back the table TEST, the third version of the table is retrieved, not the first. So the column COL1 will have the value 3, not 1.
you can also retrieve the other versions of the dropped table
- Use the rename option:
SQL>FLASHBACK TABLE TEST TO BEFORE DROP RENAME TO TEST2;
SQL>FLASHBACK TABLE TEST TO BEFORE DROP RENAME TO TEST1;
- Use the specific recycle-bin names of the table to restore. To do that, first identify the table's recycle bin names and then issue:
SQL>FLASHBACK TABLE "BIN$04LhcpnoanfgMAAAAAANPw==$0" TO BEFORE DROP RENAME TO TEST2;
SQL>FLASHBACK TABLE "BIN$04LhcpnqanfgMAAAAAANPw==$0" TO BEFORE DROP RENAME TO TEST1;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/207/viewspace-778638/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20190805]Oracle 12c New Feature – Online Partitioning.txtOracle
- SAP Table function 執行報錯 feature not supported 該如何分析Function
- Feature homophily metric
- oracle10g審計(轉)Oracle
- about oracle10g rac(轉)Oracle
- 7.92 FEATURE_VALUE
- 7.91 FEATURE_SET
- 7.90 FEATURE_ID
- 7.89 FEATURE_DETAILSAI
- 7.88 FEATURE_COMPARE
- new self()與new static()
- oracle10g RMAN增量備份策略Oracle
- ORACLE10G升級11GOracle
- Gaming Dongle Feature Application NoteGAMAPP
- 【譯】Android Gradle 外掛 4.0.0 中 Feature-on-Feature 的依賴關係AndroidGradle
- New
- create table,show tables,describe table,DROP TABLE,ALTER TABLE ,怎麼使用?
- JavaScript中的new map()和new set()使用詳細(new map()和new set()的區別)JavaScript
- Oracle10g刪除資料檔案Oracle
- A2A (SOUL-Quiz FeatureUI
- 理解new和實現一個new
- a new blog
- in place new
- a new ideaIdea
- new learn
- Oracle10g SQL tune adviser簡單介紹OracleSQL
- oracle10g DataGuard的日誌傳輸方式Oracle
- Oracle10g釋放flash_recovery_area(轉)Oracle
- PHP new self()和new static()的區別PHP
- How to Add a New Disk new partition in centos7CentOS
- allure功能使用-feature&story
- Feature Mask Network for Person Re-identificationIDE
- table
- new static ,new self ,self::, $this的一些理解
- javascript 中function(){},new function(),new Function(),Function 摘錄JavaScriptFunction
- My New GoalGo
- D - New Friends
- New Year and Days
- new筆記筆記