Oracle recyclebin介紹
近日為某客戶做資料庫巡檢,發現資料庫recycle bin中有幾千個被刪除的物件,於是建議客戶清理recycle bin中的物件,釋放空間,客戶問這些物件佔用空間嗎?存放在哪裡的?
這些被刪除的物件當然是存放在硬碟上的,官方方檔介紹recycle bin 如下:
The recycle bin is actually a data dictionary table containing information about dropped objects. Dropped tables and any associated objects such as indexes,
constraints, nested tables, and the likes are not removed and still occupy space. They continue to count against user space quotas, until specifically purged
from the recycle bin or the unlikely situation where they must be purged by the database because of tablespace space constraints
recycle bin事實上是一個資料字典表,包含被刪除物件的資訊,例如:表、索引、約束等,recycle bin中被刪除的物件不會被remove,仍然佔用空間。
Each user can be thought of as having his own recycle bin, since unless a user has the SYSDBA privilege, the only objects that the user has access to in the
recycle bin are those that the user owns. A user can view his objects in the recycle bin using the following statement:SELECT * FROM RECYCLEBIN;
每個使用者都有自己的recycle bin,物件的擁有者都可以訪問自己的recycle bin,除非具有sysdba許可權,可以透過select * from recyclebin查詢,預設recycle bin是開啟的。
1、禁用recycle bin:
ALTER SESSION SET recyclebin = OFF;
ALTER SYSTEM SET recyclebin = OFF;
2、開啟recycle bin:
ALTER SESSION SET recyclebin = ON;
ALTER SYSTEM SET recyclebin = ON;
測試:
1、建立表空間
SYS@jzh>create tablespace recycle datafile '/u01/app/oracle/oradata/jzh/recycle' size 10M;
Tablespace created.
2、建立用與測試表
SYS@jzh>create user test identified by test default tablespace recycle;
User created.
SYS@jzh>grant dba to test;
Grant succeeded.
SYS@jzh>conn test/test
Connected.
TEST@jzh>create table test as select * from dba_objects;
Table created.
3、刪除test表
TEST@jzh>select * from recyclebin;
no rows selected
TEST@jzh>drop table test;
Table dropped.
TEST@jzh>select OBJECT_NAME,ORIGINAL_NAME,OPERATION,TYPE,DROPTIME from recyclebin;
OBJECT_NAME ORIGINAL_NAME OPERATION TYPE DROPTIME
------------------------------ -------------------------------- --------- ------------------------- -------------------
BIN$GJ+BrKeuDfDgU28BqMAPIg==$0 TEST DROP TABLE 2015-06-16:16:39:03
4、查詢test使用者下物件
TEST@jzh>select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BIN$GJ+BrKeuDfDgU28BqMAPIg==$0 TABLE
5、查詢物件BIN$GJ+BrKeuDfDgU28BqMAPIg==$0所在表空間,大小等資訊
TEST@jzh>select SEGMENT_NAME,SEGMENT_TYPE,TABLESPACE_NAME,BYTES,BLOCKS from user_segments where segment_name='BIN$GJ+BrKeuDfDgU28BqMAPIg==$0';
SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME BYTES BLOCKS
--------------------------------------------------------------------------------- ------------------ ------------------------------ ---------- ----------
BIN$GJ+BrKeuDfDgU28BqMAPIg==$0 TABLE RECYCLE 8716288 1064
以上可以看出BIN$GJ+BrKeuDfDgU28BqMAPIg==$0物件依然儲存在recycle表空間,大小為8716288位元組,共1064個blocks
總結:1、被drop之後的表依然儲存在原位置,大小無變化,佔用空間;
2、在原位置被drop的物件被標記為可覆蓋;
3、當原表空間無free的空間時,該位置就會被覆蓋;
這些被刪除的物件當然是存放在硬碟上的,官方方檔介紹recycle bin 如下:
The recycle bin is actually a data dictionary table containing information about dropped objects. Dropped tables and any associated objects such as indexes,
constraints, nested tables, and the likes are not removed and still occupy space. They continue to count against user space quotas, until specifically purged
from the recycle bin or the unlikely situation where they must be purged by the database because of tablespace space constraints
recycle bin事實上是一個資料字典表,包含被刪除物件的資訊,例如:表、索引、約束等,recycle bin中被刪除的物件不會被remove,仍然佔用空間。
Each user can be thought of as having his own recycle bin, since unless a user has the SYSDBA privilege, the only objects that the user has access to in the
recycle bin are those that the user owns. A user can view his objects in the recycle bin using the following statement:SELECT * FROM RECYCLEBIN;
每個使用者都有自己的recycle bin,物件的擁有者都可以訪問自己的recycle bin,除非具有sysdba許可權,可以透過select * from recyclebin查詢,預設recycle bin是開啟的。
1、禁用recycle bin:
ALTER SESSION SET recyclebin = OFF;
ALTER SYSTEM SET recyclebin = OFF;
2、開啟recycle bin:
ALTER SESSION SET recyclebin = ON;
ALTER SYSTEM SET recyclebin = ON;
測試:
1、建立表空間
SYS@jzh>create tablespace recycle datafile '/u01/app/oracle/oradata/jzh/recycle' size 10M;
Tablespace created.
2、建立用與測試表
SYS@jzh>create user test identified by test default tablespace recycle;
User created.
SYS@jzh>grant dba to test;
Grant succeeded.
SYS@jzh>conn test/test
Connected.
TEST@jzh>create table test as select * from dba_objects;
Table created.
3、刪除test表
TEST@jzh>select * from recyclebin;
no rows selected
TEST@jzh>drop table test;
Table dropped.
TEST@jzh>select OBJECT_NAME,ORIGINAL_NAME,OPERATION,TYPE,DROPTIME from recyclebin;
OBJECT_NAME ORIGINAL_NAME OPERATION TYPE DROPTIME
------------------------------ -------------------------------- --------- ------------------------- -------------------
BIN$GJ+BrKeuDfDgU28BqMAPIg==$0 TEST DROP TABLE 2015-06-16:16:39:03
4、查詢test使用者下物件
TEST@jzh>select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BIN$GJ+BrKeuDfDgU28BqMAPIg==$0 TABLE
5、查詢物件BIN$GJ+BrKeuDfDgU28BqMAPIg==$0所在表空間,大小等資訊
TEST@jzh>select SEGMENT_NAME,SEGMENT_TYPE,TABLESPACE_NAME,BYTES,BLOCKS from user_segments where segment_name='BIN$GJ+BrKeuDfDgU28BqMAPIg==$0';
SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME BYTES BLOCKS
--------------------------------------------------------------------------------- ------------------ ------------------------------ ---------- ----------
BIN$GJ+BrKeuDfDgU28BqMAPIg==$0 TABLE RECYCLE 8716288 1064
以上可以看出BIN$GJ+BrKeuDfDgU28BqMAPIg==$0物件依然儲存在recycle表空間,大小為8716288位元組,共1064個blocks
總結:1、被drop之後的表依然儲存在原位置,大小無變化,佔用空間;
2、在原位置被drop的物件被標記為可覆蓋;
3、當原表空間無free的空間時,該位置就會被覆蓋;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10271187/viewspace-1703350/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【RECYCLEBIN】Oracle回收站詳解Oracle
- 【Oracle】Oracle logminer功能介紹Oracle
- Oracle ADR介紹Oracle
- ORACLE OWI介紹Oracle
- Oracle DRM原理介紹Oracle
- 「Oracle」Oracle高階查詢介紹Oracle
- 1、Oracle 基礎介紹Oracle
- 【NULL】Oracle null值介紹NullOracle
- ORACLE MTS的介紹(zt)Oracle
- oracle常用函式介紹Oracle函式
- Oracle補丁介紹一Oracle
- 【SCN】Oracle SCN 詳細介紹Oracle
- 11_Oracle bbed工具介紹Oracle
- Oracle 統計資訊介紹Oracle
- Oracle cluster table(1)_概念介紹Oracle
- 【FLASHBACK】Oracle flashback data archive 介紹OracleHive
- 關於Oracle Database Vault介紹OracleDatabase
- oracle 大頁配置詳細介紹Oracle
- LGnn 程式介紹(oracle 19c)GNNOracle
- 【DBMS】Oracle DBMS_OUTOUT程式介紹Oracle
- Oracle 備份和恢復介紹Oracle
- 原創:oracle聚合函式介紹Oracle函式
- 原創:oracle 子查詢介紹Oracle
- 原創:oracle DML介紹與使用Oracle
- Oracle資料庫審計功能介紹Oracle資料庫
- ORACLE 12C Cloud Control(二)介紹OracleCloud
- 簡單介紹oracle重置序列的方法Oracle
- Oracle RAC DRM介紹和關閉DRMOracle
- Oracle認證介紹及入門心得Oracle
- Oracle10g的回收站(recyclebin)和自由空間管理Oracle
- oracle複合索引介紹(多欄位索引)Oracle索引
- LightDB/postgresql內建特性之訪問oracle之oracle_fdw介紹SQLOracle
- 【TUNE_ORACLE】Oracle檢查點(一)檢查點(Checkpoint)概念介紹Oracle
- 【Oracle體系結構】 Oracle19C 系統結構介紹Oracle
- 【RAC】Oracle RAC上線測試場景介紹Oracle
- Oracle10g SQL tune adviser簡單介紹OracleSQL
- 【AWR】Oracle awr相關檢視及體系介紹Oracle
- ORACLE 12C RAC 生產環境搭建介紹Oracle
- 【SQL】SQL表連線方法方式介紹(Oracle/Postgresql)SQLOracle