Oracle常用脚本-查看表空间使用情况

来源:互联网 发布:淘宝pc端首页装修 编辑:程序博客网 时间:2024/06/07 06:02

CREATE OR REPLACE VIEW db_used
AS
select b.file_id  ,
  b.tablespace_name  ,
  b.file_name     ,
  b.bytes /1024/1024      total_mb,
  (b.bytes-sum(nvl(a.bytes,0)))/1024/1024   used_mb,
  sum(nvl(a.bytes,0))/1024/1024    remain_mb,
  sum(nvl(a.bytes,0))/(b.bytes)*100 remain_percent
  from dba_free_space a,dba_data_files b
  where a.file_id=b.file_id
  group by b.tablespace_name,b.file_name,b.file_id,b.bytes
  order by b.tablespace_name
/