分享几个平时工作中比较常用的几个表空间查询的脚本:
1、常看表空间的使用情况
SELECT a.tablespace_name, total, free,(total - free), ROUND((total - free) / total, 4) * 100
FROM (SELECT tablespace_name, ROUND(SUM(bytes) / (1024 * 1024), 4) free
FROM DBA_FREE_SPACE
GROUP BY tablespace_name) a,
(SELECT tablespace_name, ROUND(SUM(bytes) / (1024 * 1024), 4) total
FROM DBA_DATA_FILES
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name;
2、查看表空间和数据文件的对应情况
select T.TS#,D.FILE#,D.NAME,D.STATUS,D.BYTES/1024/1024
from v$tablespace T, v$datafile D
where T.ts# = D.ts#;
3、查看表空间中占用空间最大的对象(在表空间异常增长的时候,经常用该语句查找对象)
select t.owner,
t.segment_name,
t.segment_type,
partition_name,
t.tablespace_name,
t.blocks * 8 / 1024/ sizem
from dba_segments t
where tablespace_name='TABLESPACE_NAME'
order by t.blocks desc
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++本文作者:JOHN
ORACLE技术博客:ORACLE 猎人笔记 数据库技术群:367875324 (请备注ORACLE管理 )
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++