科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道oracle数据库表空间监控实用脚本

oracle数据库表空间监控实用脚本

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

1.查看某个表空间内所占空间大于某个值的段(表或索引): SELECT segment_name,bytes FROM dba_segments WHERE bytes>10000000 AND tablespace_name='tablespa

作者:中国IT实验室 来源:中国IT实验室 2007年10月5日

关键字: 监控 表空间 数据库 ORACLE

  • 评论
  • 分享微博
  • 分享邮件
1.查看某个表空间内所占空间大于某个值的段(表或索引):
  SELECT segment_name,bytes FROM dba_segments WHERE bytes>10000000 AND tablespace_name='tablespace_name';

2.查看某个表空间内最大连续的自由空间大小:
  SELECT tablespace_name,max(bytes) FROM dba_free_space GROUP BY tablespace_name ORDER BY max(bytes);

3.查看所有表空间的碎片程度(值在30以下表示碎片很多)
select tablespace_name,sum(bytes),sum(free),sum(free)*100/sum(bytes) from   (select
  b.file_id file_ID,
  b.tablespace_name tablespace_name,
  b.bytes Bytes,
  (b.bytes-sum(nvl(a.bytes,0))) used,
  sum(nvl(a.bytes,0)) free,
  sum(nvl(a.bytes,0))/(b.bytes)*100       Percent
  from dba_free_space a,dba_data_files b
  where a.file_id=b.file_id
  group by b.tablespace_name,b.file_id,b.bytes
  order by b.file_id) group by tablespace_name order by sum(free)*100/sum(bytes);

4.迅速收缩临时段(适用于临时段表空间收缩很慢的情况)
  alter tablespace temp default storage(pctincrease 1);
  alter tablespace temp default storage(pctincrease 0);

5.查看自上次数据库启动以来所有数据文件的读写次数
  select
    substr(DF.NAME,1,5) Drive,
    DF.NAME file_name,
    (fs.phyblkrd+fs.phyblkwrt)
  from v$filestat fs,v$datafile df
    where df.file#=fs.file#;

6.查看某用户下段存储的大小
  select SEGMENT_NAME,BYTES from dba_segments where segment_type='TABLE' and owner='owner_name' ;
  select SEGMENT_NAME,BYTES from dba_segments where segment_type='INDEX' and owner='owner_name' ;
由于oracle提供的oem工具的局限性,所以很多时候dba必需借助于一些脚本来管理、调优数据库。

查看本文来源

    • 评论
    • 分享微博
    • 分享邮件