ITPub博客

首页 > 数据库 > Oracle > 数据库表空间监控视图

数据库表空间监控视图

原创 Oracle 作者:xxgoracle 时间:2006-10-31 13:15:54 0 删除 编辑
自己建了个视图来监控数据库的表空间资源[@more@]

代码如下:

CREATE OR REPLACE VIEW DB_TBSPACE_CHECK AS
SELECT a.TBSPACE_NAME AS TBSPACE_NAME,
ROUND(a.Total_MB,2) AS Total_MB,
ROUND(b.Free_MB,2) AS Free_MB,
ROUND((NVL(a.Total_MB,0)-NVL(b.Free_MB,0)),2) AS Used_MB,
ROUND(DECODE(NVL(a.Total_MB,0),0,0,
(NVL(a.Total_MB,0)-NVL(b.Free_MB,0))*100/NVL(a.Total_MB,0)),2)||'%' AS Used_Rate,
ROUND(DECODE(NVL(a.Total_MB,0),0,0,
NVL(b.Free_MB,0)*100/NVL(a.Total_MB,0)),2)||'%' AS Free_Rate
FROM (SELECT TABLESPACE_NAME AS TBSPACE_NAME,
SUM(BYTES)/1024/1024 AS Total_MB
FROM DBA_DATA_FILES t
GROUP BY TABLESPACE_NAME) a,

(SELECT TABLESPACE_NAME AS TBSPACE_NAME,
SUM(BYTES)/1024/1024 AS Free_MB
FROM DBA_FREE_SPACE t
GROUP BY TABLESPACE_NAME) b
WHERE a.TBSPACE_NAME = b.TBSPACE_NAME

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/20546452/viewspace-874496/,如需转载,请注明出处,否则将追究法律责任。

上一篇: ORA-00600 [15201]
下一篇: ORA-00600 [12830]
请登录后发表评论 登录
全部评论
  • 博文量
    37
  • 访问量
    519459