Oracle 表字段定义CLOB类型导致系统文件占用大,导致表空间被占满,需要清理。
如下表中定义CLOB类型字段。
select table_name, column_name, segment_name, a.bytes from dba_segments a join dba_lobs b using (owner, segment_name)
where b.table_name = 'V_ESBHLP_EMRDOC_INFO';
运行truncate会释放空间
truncate table V_ESBHLP_EMRDOC_INFO;
查找表空间的使用情况
select a.tablespace_name as "表空间名",
a.bytes / 1024 / 1024 as "表空间大小(M)",
(a.bytes - b.bytes) / 1024 / 1024 as "已使用空间(M)",
b.bytes / 1024 / 1024 "空闲空间(M)",
round(((a.bytes - b.bytes) / a.bytes) * 100, 2) "使用比"
from (select tablespace_name, sum(bytes) bytes
from dba_data_files
group by tablespace_name) a,
(select tablespace_name, sum(bytes) bytes, max(bytes) largest
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
order by ((a.bytes - b.bytes) / a.bytes) desc;