Chinaunix首页 | 论坛 | 博客
  • 博客访问: 579942
  • 博文数量: 718
  • 博客积分: 4000
  • 博客等级: 上校
  • 技术积分: 4960
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-17 13:24
文章分类

全部博文(718)

文章存档

2011年(1)

2008年(717)

我的朋友

分类:

2008-10-17 13:25:39

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必需借助于一些脚本来管理、调优数据库。

【责编:Peng】

--------------------next---------------------

阅读(287) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~