dba_free_space 以及查询剩余表空间百分比和回滚段命中率的SQL
2008-12-18 10:42
393 查看
dba_free_space 显示的是有free 空间的tablespace ,如果一个tablespace 的free 空间不连续,那每段free空间都会在dba_free_space中存在一条记录。如果一个tablespace 有好几条记录,说明表空间存在碎片,当采用字典管理的表空间碎片超过500就需要对表空间进行碎片整理。
select tablespace_name,sum(bytes) 总字节数,max(bytes),count(*) from dba_free_space group by tablespace_name;
count大于500 要考虑一下了 是否需要整理
或者
SQL> select a.tablespace_name ,count(1) 碎片量 from dba_free_space a, dba_tablespaces b
2 where a.tablespace_name=b.tablespace_name
3 and b.extent_management = 'DICTIONARY'
4 group by a.tablespace_name
5 having count(1) >20
6 order by 2;
能否查到tablespace_name
表空间碎片整理语法:
alter tablespace [tablespace_name] coalesce;
===============================================================================================
剩余表空间百分比
select df.tablespace_name "表空间名",totalspace "总空间M",freespace "剩余空间M",round((1-freespace/totalspace)*100,2) "使用率%" from (select tablespace_name,round(sum(bytes)/1024/1024) totalspace from dba_data_files group by tablespace_name) df, (select tablespace_name,round(sum(bytes)/1024/1024) freespace from dba_free_space group by tablespace_name) fs where df.tablespace_name=fs.tablespace_name;
表空间名 总空间M 剩余空间M 使用率%
------------------------------ ---------- ---------- ----------
AA 5 5 0
UNDOTBS1 25 21 16
SYSAUX 260 13 95
USERS 5 5 0
SYSTEM 480 5 98.96
==================================================================================================
回滚段命中率
select rn.name,rs.gets 被访问次数,rs.waits 等待回退段块的次数,(rs.waits/rs.gets)*100 命中率 from v$rollstat rs,v$rollname rn
select tablespace_name,sum(bytes) 总字节数,max(bytes),count(*) from dba_free_space group by tablespace_name;
count大于500 要考虑一下了 是否需要整理
或者
SQL> select a.tablespace_name ,count(1) 碎片量 from dba_free_space a, dba_tablespaces b
2 where a.tablespace_name=b.tablespace_name
3 and b.extent_management = 'DICTIONARY'
4 group by a.tablespace_name
5 having count(1) >20
6 order by 2;
能否查到tablespace_name
表空间碎片整理语法:
alter tablespace [tablespace_name] coalesce;
===============================================================================================
剩余表空间百分比
select df.tablespace_name "表空间名",totalspace "总空间M",freespace "剩余空间M",round((1-freespace/totalspace)*100,2) "使用率%" from (select tablespace_name,round(sum(bytes)/1024/1024) totalspace from dba_data_files group by tablespace_name) df, (select tablespace_name,round(sum(bytes)/1024/1024) freespace from dba_free_space group by tablespace_name) fs where df.tablespace_name=fs.tablespace_name;
表空间名 总空间M 剩余空间M 使用率%
------------------------------ ---------- ---------- ----------
AA 5 5 0
UNDOTBS1 25 21 16
SYSAUX 260 13 95
USERS 5 5 0
SYSTEM 480 5 98.96
==================================================================================================
回滚段命中率
select rn.name,rs.gets 被访问次数,rs.waits 等待回退段块的次数,(rs.waits/rs.gets)*100 命中率 from v$rollstat rs,v$rollname rn
相关文章推荐
- ORA FAQ 性能调整系列之——本地管理表空间环境下查询dba_free_space很慢——有什么办法加速么?
- SQL查询服务器硬盘剩余空间
- 8i查询DBA_FREE_SPACE视图极慢的问题
- DBA常用sql语句-查询表空间大小语句
- DBA_FREE_SPACE查询慢的原因及解决方法
- Scripts:查询数据库中表空间的情况汇总dba_tablespaces.sql
- 8i查询DBA_FREE_SPACE视图极慢的问题
- sql查询表大小行数以及使用空间
- dba_free_space 等表空间的视图不能在过程中被使用的问题解决
- sql 查询服务器硬盘剩余空间
- Scripts:查询数据库中各个表空间信息汇总dba_tablespace_to_owner.sql
- 查询表空间剩余空间百分比的错误方法纠正
- (2011-01-27)通过dba_free_space视图查看表空间的空间分配过程
- sql查询数据库中所有表的记录条数,以及占用磁盘空间大小。
- 获取磁盘类型及剩余空间 GetDiskFreeSpaceEx GetDriveTypeW GetVolumeInformation
- oracle表空间使用情况查询sql以及图形化修改表空间
- 答:SQLServer DBA 三十问之一: char、varchar、nvarchar之间的区别(包括用途和空间占用);xml类型查找某个节点的数据有哪些方法,哪个效率高;使用存储 过程和使用T-SQL查询数据有啥不一样;
- 获得磁盘剩余空间:GetDiskFreeSpaceEx
- Oracle查询表空间使用大小,使用率,剩余大小,百分比
- Scripts:报告数据库中对应对象用户表空间的段情况汇总dba_owner_to_tablespace.sql