码迷,mamicode.com
首页 > 数据库 > 详细

数据库如何查看表空间的使用率

时间:2018-01-25 20:40:48      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:ade   round   51cto   extent   rac   gty   percent   sort   sadd   

进入oracle数据库中,输入以下代码即可
select total.tablespace_name,
round(total.MB, 2) as Total_MB,
round(total.MB - free.MB, 2) as Used_MB,
round((1 - free.MB / total.MB) 100, 2) || ‘%‘ as Used_Pct
from (select tablespace_name, sum(bytes) / 1024 / 1024 as MB
from dba_free_space
group by tablespace_name) free,
(select tablespace_name, sum(bytes) / 1024 / 1024 as MB
from dba_data_files
group by tablespace_name) total
where free.tablespace_name = total.tablespace_name;
技术分享图片
SELECT a.tablespace_name, a.BYTES total, a.bytes - nvl(b.bytes, 0) free FROM (SELECT tablespace_name, SUM (bytes) bytes FROM dba_temp_files GROUP BY tablespace_name) a,(SELECT tablespace_name, SUM (bytes_cached) bytes FROM v$temp_extent_pool GROUP BY tablespace_name) b WHERE a.tablespace_name = b.tablespace_name(+)
技术分享图片
SELECT temp_used.tablespace_name,total - used as "Free",total as "Total",round(nvl(total - used, 0)
100 / total, 3) "Free percent" FROM (SELECT tablespace_name, SUM(bytesused) / 1024 / 1024 used FROM GV$TEMP_SPACE_HEADER GROUP BY tablespace_name) temp_used,(SELECT tablespace_name, SUM(bytes) / 1024 / 1024 total FROM dba_temp_files GROUP BY tablespace_name) temp_total WHERE temp_used.tablespace_name = temp_total.tablespace_name;
技术分享图片

那些语句待用临时表空间
SELECT se.username,sid,serial#,sql_address,machine,program,tablespace,segtype,contents FROM v$session se, v$sort_usage su WHERE se.saddr = su.session_addr;

数据库如何查看表空间的使用率

标签:ade   round   51cto   extent   rac   gty   percent   sort   sadd   

原文地址:http://blog.51cto.com/795580/2065190

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!