oracle 回收站
回收站(RecycleBin)是一個資料字典表,放置使用者刪除(drop)掉的資料庫物件資訊。使用者進行刪除操作的物件並沒有被資料庫刪除,仍然會佔用空間。如果一個表被刪除,那麼與該表有關聯的物件,例如表、索引、約束和其他依賴物件都會在前面加bin$$這個字首。
hr@HX> create table t as select * from dba_objects;
Table created.
hr@HX> create index idx_t_id on t(object_id);
Index created.
hr@HX> drop table t;
Table dropped.
hr@HX> select object_name,ORIGINAL_NAME,OPERATION,TYPE,SPACE from RECYCLEBIN;
OBJECT_NAME |ORIGINAL_NAME |OPERATION|TYPE | SPACE
------------------------------|--------------------------------|---------|-------------------------|----------
BIN$7hpJclDOBi3gQwEAAH+23A==$0|T |DROP |TABLE | 256
BIN$7hpJclDNBi3gQwEAAH+23A==$0|IDX_T_ID |DROP |INDEX | 40
2 rows selected.
1.回收站功能啟動和關閉
回收站功能受引數recyclebin影響,預設是開啟的
hr@HX> show parameter recyclebin;
NAME |TYPE |VALUE
------------------------------------|-----------|------------------------------
recyclebin |string |on
可以在會話或者系統級別開啟或者關閉回收站功能:
ALTER SYSTEM SET recyclebin = ON;
ALTER SESSION SET recyclebin = ON;
ALTER SYSTEM SET recyclebin = OFF;
ALTER SESSION SET recyclebin = OFF;
獲取回收站裡的內容
SELECT * FROM RECYCLEBIN;
SELECT * FROM USER_RECYCLEBIN;
SELECT * FROM DBA_RECYCLEBIN;
2.從回收站還原表:
刪除表後,可以利用回收站還原:
FLASHBACK TABLE <
這裡的RENAME是給刪除的物件進行重新命名,可選:
hr@HX> flashback table t to before drop rename to t1;
Flashback complete.
hr@HX> select object_name,ORIGINAL_NAME,OPERATION,TYPE,SPACE from RECYCLEBIN;
no rows selected
恢復後索引仍然可以使用:
hr@HX> select index_name,table_name,status from user_indexes where table_name='T1';
INDEX_NAME |TABLE_NAME |STATUS
-------------------------|---------------|--------
BIN$7hpJclDNBi3gQwEAAH+23|T1 |VALID
A==$0 | |
1 row selected.
hr@HX> select count(object_id) from t1;
COUNT(OBJECT_ID)
----------------
15596
1 row selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 572134920
--------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 13 | 12 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 13 | | |
| 2 | INDEX FAST FULL SCAN| BIN$7hpJclDNBi3gQwEAAH+23A==$0 | 18409 | 233K| 12 (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------------
3. 清空回收站
清空回收站包含兩種情況,有條件清空和全部清空
(1)清空特定的表:
PURGE TABLE <
>; hr@HX> select object_name,ORIGINAL_NAME,OPERATION,TYPE,SPACE from RECYCLEBIN;
OBJECT_NAME |ORIGINAL_NAME |OPERATION|TYPE | SPACE
------------------------------|--------------------------------|---------|---------------|----------
BIN$7hpJclDQBi3gQwEAAH+23A==$0|T1 |DROP |TABLE | 256
BIN$7hpJclDPBi3gQwEAAH+23A==$1|BIN$7hpJclDNBi3gQwEAAH+23A==$0 |DROP |INDEX | 40
2 rows selected.
hr@HX> purge table t1;
Table purged.
hr@HX> select object_name,ORIGINAL_NAME,OPERATION,TYPE,SPACE from RECYCLEBIN;
no rows selected
和表相關的物件會被一併清除
(2)清空一個特定的索引:
PURGE INDEX <
>; hr@HX> select object_name,ORIGINAL_NAME,OPERATION,TYPE,SPACE from RECYCLEBIN;
OBJECT_NAME |ORIGINAL_N|OPERATION|TYPE | SPACE
------------------------------|----------|---------|----------|----------
BIN$7hpJclDSBi3gQwEAAH+23A==$0|T |DROP |TABLE | 256
BIN$7hpJclDRBi3gQwEAAH+23A==$0|IDX_T_ID |DROP |INDEX | 40
2 rows selected.
hr@HX> purge index idx_t_id;
Index purged.
hr@HX> select object_name,ORIGINAL_NAME,OPERATION,TYPE,SPACE from RECYCLEBIN;
OBJECT_NAME |ORIGINAL_N|OPERATION|TYPE | SPACE
------------------------------|----------|---------|----------|----------
BIN$7hpJclDSBi3gQwEAAH+23A==$0|T |DROP |TABLE | 256
1 row selected.
(3)清空與該表空間有關聯的物件:
PURGE TABLESPACE <
>; hr@HX> select object_name,ORIGINAL_NAME,OPERATION,TYPE,SPACE,ts_name from RECYCLEBIN;
OBJECT_NAME |ORIGINAL_N|OPERATION|TYPE | SPACE|TS_NAME
------------------------------|----------|---------|----------|----------|------------------------------
BIN$7hpJclDSBi3gQwEAAH+23A==$0|T |DROP |TABLE | 256|HR
1 row selected.
hr@HX> purge tablespace hr;
Tablespace purged.
hr@HX> select object_name,ORIGINAL_NAME,OPERATION,TYPE,SPACE,ts_name from RECYCLEBIN;
no rows selected
(4)清空一個表空間中特定使用者的資訊:
hr@HX> select object_name,ORIGINAL_NAME,OPERATION,TYPE,SPACE,ts_name from RECYCLEBIN;
OBJECT_NAME |ORIGINAL_N|OPERATION|TYPE | SPACE|TS_NAME
------------------------------|----------|---------|----------|----------|---------------
BIN$7hpJclDWBi3gQwEAAH+23A==$0|T |DROP |TABLE | 256|HR
BIN$7hpJclDVBi3gQwEAAH+23A==$0|IDX_T_ID |DROP |INDEX | 256|HR_20M
2 rows selected.
hr@HX> purge tablespace hr_20m user hr;
Tablespace purged.
hr@HX> select object_name,ORIGINAL_NAME,OPERATION,TYPE,SPACE,ts_name from RECYCLEBIN;
OBJECT_NAME |ORIGINAL_N|OPERATION|TYPE | SPACE|TS_NAME
------------------------------|----------|---------|----------|----------|----------------
BIN$7hpJclDWBi3gQwEAAH+23A==$0|T |DROP |TABLE | 256|HR
1 row selected.
(5)清空回收站(比較常用):
PURGE RECYCLEBIN;
(6)刪除表時直接清除回收站資訊:
DROP TABLE <
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28813259/viewspace-1063997/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle—回收站Oracle
- oracle 回收站功能Oracle
- Oracle 回收站清理Oracle
- 清除oracle回收站Oracle
- Oracle回收站機制Oracle
- Oracle回收站介紹Oracle
- 【RECYCLEBIN】Oracle回收站詳解Oracle
- Oracle回收站的清理方法Oracle
- oracle回收站,搬運工Oracle
- 清除oracle的recyclebin回收站Oracle
- oracle清空回收站中資料Oracle
- oracle回收站的關閉Oracle
- Oracle 10 Recycle Bin回收站(轉)Oracle
- Oracle回收站及flashback drop(上)Oracle
- Oracle回收站及flashback drop(下)Oracle
- Oracle中的回收站(Recycle Bin)Oracle
- 常見問題--oracle 回收站Oracle
- 【recyclebin】徹底禁用 Oracle回收站功能Oracle
- Oracle 10G 中的回收站Oracle 10g
- Oracle 10G 中的"回收站"Oracle 10g
- Oracle回收站表閃回機制研究Oracle
- Oracle 10G 中的"回收站"(轉)Oracle 10g
- Oracle回收站功能開啟與關閉Oracle
- Oracle10g新特性:Recycle Bin回收站Oracle
- oracle10g 清除回收站中垃圾表Oracle
- Oracle10g 中的回收站(Recycle Bin)Oracle
- 【FLASHBACK】Oracle閃回及回收站相關語句參考Oracle
- 【Oracle】-【recyclebin,索引】-回收站恢復的索引名稱修改Oracle索引
- Oracle10g的回收站(recyclebin)和自由空間管理Oracle
- ORACLE 11.2.0.4版本EXPDP不會匯出回收站中資料Oracle
- Linux回收站Linux
- Oracle10g的回收站(recyclebin)和自由空間管理(zt)Oracle
- 【新炬網路名師大講堂】Oracle中的回收站(Recycle Bin)Oracle
- win10 如何恢復回收站_win10回收站恢復方法Win10
- linux 回收站的新增Linux
- linux 回收站 路徑Linux
- win10如何去掉桌面回收站_win10刪除桌面回收站的方法Win10
- flashback回收站知識彙總