delete不釋放表空間
只是delete行,原來所佔用的空間不能被別的物件所用。
只有drop了物件之後,才能被別的物件使用。
只是刪除資料,表空間使用率,不會變化。物件佔用的大小也不會變化
SQL> create tablespace t_test datafile '/data/t_test01.dbf' size 5m autoextend off;
Tablespace created.
SQL> drop table test purge;
drop table test purge
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> create table test tablespace t_test as select * from dba_objects where 1=0 ;
Table created.
SQL> insert into test select * from dba_objects where rownum<1000;
999 rows created.
SQL> /
999 rows created.
SQL> /
999 rows created.
SQL> /
insert into test select * from dba_objects where rownum<1000
*
ERROR at line 1:
ORA-01653: unable to extend table SONG.TEST by 128 in tablespace T_TEST
SQL> /
insert into test select * from dba_objects where rownum<1000
*
ERROR at line 1:
ORA-01653: unable to extend table SONG.TEST by 128 in tablespace T_TEST
SQL> commit;
Commit complete.
SQL> exec dbms_stats.gather_table_stats('SONG','TEST');
PL/SQL procedure successfully completed.
SQL> select bytes/1024/1024 from dba_segments where segment_name='TEST';
BYTES/1024/1024
---------------
4
SQL> CREATE TABLE T2 TABLESPACE T_TEST AS SELECT * FROM DBA_OBJECTS WHERE 1=0;
Table created.
SQL> INSERT INTO T2 SELECT * FROM DBA_OBJECTS WHERE ROWNUM<500;
INSERT INTO T2 SELECT * FROM DBA_OBJECTS WHERE ROWNUM<500
*
ERROR at line 1:
ORA-01658: unable to create INITIAL extent for segment in tablespace T_TEST
SQL> delete from test; --刪除表中所有的資料
38961 rows deleted.
SQL> commit;
Commit complete.
SQL> INSERT INTO T2 SELECT * FROM DBA_OBJECTS WHERE ROWNUM<500; --刪除的空間不能為別的物件所用
INSERT INTO T2 SELECT * FROM DBA_OBJECTS WHERE ROWNUM<500
*
ERROR at line 1:
ORA-01658: unable to create INITIAL extent for segment in tablespace T_TEST
SQL> drop table test purge ; --刪除物件之後, 別的物件才能用
Table dropped.
SQL> INSERT INTO T2 SELECT * FROM DBA_OBJECTS WHERE ROWNUM<500;
499 rows created.
SQL> commit;
Commit complete.
SQL> set line 200
SQL> SELECT A.TABLESPACE_NAME,A.BYTES/1024/1024 TOTAL,B.BYTES/1024/1024 USED, C.BYTES/1024/1024 FREE,
2 (B.BYTES*100)/A.BYTES "% USED ",(C.BYTES*100)/A.BYTES "% FREE "
3 FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C
4 WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME AND a.tablespace_name='SONG_TS';
TABLESPACE_NAME TOTAL USED FREE % USED % FREE
------------------------------ ---------- ---------- ---------- ---------- ----------
SONG_TS 1500 9.25 1488.75 .616666667 99.25
SQL> create table test tablespace song_ts as select * from dba_objects;
Table created.
SQL> insert into test select * from test;
74963 rows created.
SQL> /
149926 rows created.
SQL> commit;
Commit complete.
SQL> SELECT A.TABLESPACE_NAME,A.BYTES/1024/1024 TOTAL,B.BYTES/1024/1024 USED, C.BYTES/1024/1024 FREE,
2 (B.BYTES*100)/A.BYTES "% USED ",(C.BYTES*100)/A.BYTES "% FREE "
3 FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C
4 WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME AND a.tablespace_name='SONG_TS';
TABLESPACE_NAME TOTAL USED FREE % USED % FREE
------------------------------ ---------- ---------- ---------- ---------- ----------
SONG_TS 1500 43.25 1454.75 2.88333333 96.9833333 --表空間用了 43M
SQL> delete from test;
299852 rows deleted.
SQL> commit;
Commit complete.
SQL> exec dbms_stats.gather_table_stats('SONG','TEST');
PL/SQL procedure successfully completed.
SQL> select bytes/1024/1024 from dba_segments where segment_name='TEST'; --刪除所有行之後,物件依然佔 34M
BYTES/1024/1024
---------------
34
SQL> SELECT A.TABLESPACE_NAME,A.BYTES/1024/1024 TOTAL,B.BYTES/1024/1024 USED, C.BYTES/1024/1024 FREE,
2 (B.BYTES*100)/A.BYTES "% USED ",(C.BYTES*100)/A.BYTES "% FREE "
3 FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C
4 WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME AND a.tablespace_name='SONG_TS';
TABLESPACE_NAME TOTAL USED FREE % USED % FREE
------------------------------ ---------- ---------- ---------- ---------- ----------
SONG_TS 1500 43.25 1454.75 2.88333333 96.9833333 --表空間使用也沒有變
SQL> drop table test purge;
Table dropped.
SQL> SELECT A.TABLESPACE_NAME,A.BYTES/1024/1024 TOTAL,B.BYTES/1024/1024 USED, C.BYTES/1024/1024 FREE,
2 (B.BYTES*100)/A.BYTES "% USED ",(C.BYTES*100)/A.BYTES "% FREE "
3 FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C
4 WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME AND a.tablespace_name='SONG_TS';
TABLESPACE_NAME TOTAL USED FREE % USED % FREE
------------------------------ ---------- ---------- ---------- ---------- ----------
SONG_TS 1500 9.25 1488.75 .616666667 99.25 --drop之後,空間使用率變了
by song
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25099483/viewspace-772801/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Sqlserver delete表部分資料釋放資料檔案空間SQLServerdelete
- 截斷表後空間不釋放的原因分析
- Oracle delete資料後的釋放表空間問題的解決 --轉Oracledelete
- Oracle 整理表碎片、釋放表的空間Oracle
- drop表空間以及對應的資料檔案後空間不釋放的問題
- SQLServer如何釋放tempdb臨時表空間SQLServer
- hpux刪除檔案後空間不釋放UX
- 如何釋放Mac空間?釋放Mac系統空間小技巧Mac
- Oracle 釋放過度使用的Undo表空間Oracle
- 解決linux下刪除檔案或oracle表空間後空間不釋放的問題LinuxOracle
- Linux 刪除檔案後空間不釋放Linux
- Linux rm掉檔案空間不釋放原因Linux
- oracle 釋放undo空間Oracle
- Delete大量資料後,回收表空間delete
- OS 刪除temp表空間 而磁碟空間未釋放的解決方案
- oracle刪除(釋放)資料檔案/表空間流程Oracle
- MongoDB Drop集合不釋放磁碟空間的解決辦法MongoDB
- Postgresql驗證_update、delete產生死亡元組,標準vacuum釋放表檔案磁碟空間的場景SQLdelete
- lsof |grep deleted 釋放磁碟空間delete
- 禪道 - 儲存空間釋放
- DATAFILE SHRINK 釋放系統空間
- Linux檔案刪除但空間不釋放問題篇Linux
- 刪除正在使用的檔案,空間不釋放的問題
- MySQL 5.7的表刪除資料後的磁碟空間釋放MySql
- 10、MySQL Case-釋放ibtmp表空間正確姿勢MySql
- 關於如何釋放表空間的問題(About Reclaimable Unused Space)AI
- Oracle資料庫高水位釋放——LOB欄位空間釋放Oracle資料庫
- (轉載)刪除檔案後硬碟空間不釋放的問題硬碟
- delete之後,快速清理表佔據的磁碟空間!delete
- set unused 是否會釋放儲存空間
- RMAN恢復單個表空間或被DROP/DELETE/TRUNCATE的表delete
- RM刪除檔案空間釋放詳解
- Linux檔案刪除空間未釋放Linux
- linux中如何解決檔案已刪除但空間不釋放的案例Linux
- 解決刪除檔案後 WSL2 磁碟空間不釋放的問題
- [待整理]oracle10g刪除(釋放)資料檔案/表空間流程Oracle
- 【實驗】兩種方法刪除表中的列與空間儲存釋放
- Mysql 刪除資料後為釋放物理空間MySql