查询一般表空间:
SELECT a.tablespace_name "表空间名",
total 表空间大小,
free 表空间剩余大小,
(total - free) 表空间使用大小,
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 = '查询的表空间名称'
查询临时表空间:
SELECT a.tablespace_name "表空间名",
total 表空间大小,
total-used 表空间剩余大小,
used 表空间使用大小,
ROUND(used / total, 4) * 100 "使用率 %"
FROM (SELECT tablespace_name, SUM(bytes_used) used
FROM v$temp_space_header
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes) total
FROM dba_temp_files
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name
and a.tablespace_name = '查询的临时表空间名称'
SELECT a.tablespace_name "表空间名",
total 表空间大小,
free 表空间剩余大小,
(total - free) 表空间使用大小,
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 = '查询的表空间名称'
查询临时表空间:
SELECT a.tablespace_name "表空间名",
total 表空间大小,
total-used 表空间剩余大小,
used 表空间使用大小,
ROUND(used / total, 4) * 100 "使用率 %"
FROM (SELECT tablespace_name, SUM(bytes_used) used
FROM v$temp_space_header
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes) total
FROM dba_temp_files
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name
and a.tablespace_name = '查询的临时表空间名称'
查询表空间大小及使用率
本文提供了一种查询Oracle数据库中一般表空间和临时表空间的大小、剩余大小及使用率的方法。通过SQL语句展示如何获取这些关键信息。
1万+

被折叠的 条评论
为什么被折叠?



