查看 Oracle 表空间的使用情况
要查看Oracle表空间的使用情况,可以使用以下SQL查询:
SELECT
df.tablespace_name AS "Tablespace",
totalusedspace AS "Used MB",
(df.totalspace - tu.totalusedspace) AS "Free MB",
df.totalspace AS "Total MB",
ROUND(100 * (totalusedspace / totalspace)) AS "% Used"
FROM
(SELECT
tablespace_name,
ROUND(SUM(bytes) / 1048576) TotalSpace
FROM
dba_data_files
GROUP BY
tablespace_name) df,
(SELECT
ROUND(SUM(bytes)/(1024*1024)) totalusedspace,
tablespace_name
FROM
dba_segments
GROUP BY
tablespace_name) tu
WHERE
df.tablespace_name = tu.tablespace_name;
这个查询结合了dba_data_files
和dba_segments
视图,以提供每个表空间的名称、已用空间、空闲空间、总空间和已用百分比。确保你有权限访问这些视图,否则你可能需要联系数据库管理员。
评论已关闭