hzcyhujw 2018-10-04
前段时间有个朋友说想看下表空间使用率、归档日志频率、闪回区使用率之类的内容,篇幅有限,今天就先分享下oracle怎么去统计表空间使用率:
select t.tablespace_name 表空间名字,d.allocated 分配的大小,u.used 使用的空间,f.free 剩余空间,t.status,d.cnt,contents,t.extent_management 扩展管理,t.segment_space_management 段管理
from dba_tablespaces t ,(select sum(bytes) allocated,count(file_id) cnt from dba_data_files where tablespace_name='&tablespace_name')d,
(select sum(bytes) free from dba_free_space where tablespace_name='&tablespace_name') f,(select sum(bytes) used from dba_segments where tablespace_name='&tablespace_name')u
where t.tablespace_name='&tablespace_name';
SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size
FROM dba_tablespaces t, dba_data_files d
WHERE t.tablespace_name = d.tablespace_name
GROUP BY t.tablespace_name;
SELECT tablespace_name,
file_id,
file_name,
round(bytes / (1024 * 1024), 0) total_space
FROM dba_data_files
ORDER BY tablespace_name;
SELECT SUM(bytes) / (1024 * 1024) AS free_space, tablespace_name
FROM dba_free_space
GROUP BY tablespace_name;
SELECT a.tablespace_name,
a.bytes total,
b.bytes used,
c.bytes free,
(b.bytes * 100) / a.bytes "% USED ",
(c.bytes * 100) / a.bytes "% FREE "
FROM sys.sm$ts_avail a, sys.sm$ts_used b, sys.sm$ts_free c
WHERE a.tablespace_name = b.tablespace_name
AND a.tablespace_name = c.tablespace_name;
SELECT FILE_NAME,TABLESPACE_NAME,AUTOEXTENSIBLE FROM dba_data_files;
上面都是我平时查表空间情况会用到的命令,觉得有用的可以收藏下。另外有什么想看的可以在下方留言,满不满足的了是另外一回事啊,当然我这边会尽量满足。
后期会抽空把归档日志频率、闪回区使用率相关内容整理分享给大家,感兴趣的话点波关注哦~