表空間釋放案例

2021-09-05 11:00:24 字數 944 閱讀 2680

某次發現資料庫中某個表空間使用率已經達到99.9%。

檢視資料庫表空間使用率:

select a.tablespace_name "表空間名", 

total "表空間大小",

free "表空間剩餘大小",

(total - free) "表空間使用大小",

total / (1024 * 1024 * 1024) "表空間大小(g)",

free / (1024 * 1024 * 1024) "表空間剩餘大小(g)",

(total - free) / (1024 * 1024 * 1024) "表空間使用大小(g)",

round((total - free) / total, 4) * 100 "使用率 %"

from (select tablespace_name, sum(bytes) free

from dba_free_space

group by tablespace_name) a,

(select tablespace_name, sum(bytes) total

from dba_data_files

group by tablespace_name) b

where a.tablespace_name = b.tablespace_name

and a.tablespace_name like '%***%';

但是查詢dba_tables和dba_indexes都查詢不到在該錶空間中的物件,檢視到對應的**站中的內容也已經刪除了。此時需要查詢dba_tab_partitions和dba_tab_subpartitions查到有對應。

釋放表空間操作,將目前的子分割槽遷移表空間:

alter table *** move subpartition p*** tablespace tbs;

truncate 釋放表空間

truncate操作,同沒有where條件的delete操作十分相似,只是把表裡的資訊全部刪除,但是表依然存在.例如 truncate table xx truncate不支援回滾,並且不能truncate乙個帶有外來鍵的表,如果要刪除首先要取消外來鍵,然後再刪除.truncate table 後,...

優化mysql表空間 mysql表空間釋放情況彙總

mysql刪除資料幾種情況以及是否釋放磁碟空間 1 drop table table name 立刻釋放磁碟空間 不管是 innodb和myisam 2 truncate table table name 立刻釋放磁碟空間 不管是 innodb和myisam truncate table其實有點類似...

oracle表空間的釋放

1.shrink space 優點 降低高水位時索引不會失效 缺點 不能將表移動到其他表空間 高水位降低效果沒有move明顯 同時在執行命令前要先執行 alter table table name enable row movement允許行移動 也會表會產生行級鎖 shrink比move更耗費cp...