Oracle数据库管理员职责(三)(2)

日期: 2008-09-21 作者:kirk_king 来源:TechTarget中国 英文

  1. Space.sql


  – space.sql
  – To check free, pct_free, and allocated space within a tablespace
  – 11/24/98
     select tablespace_name, largest_free_chunk, nr_free_chunks, sum_alloc_blocks, sum_free_blocks
  , to_char(100*sum_free_blocks/sum_alloc_blocks, ’09.99’) || ’%’ AS pct_free
  FROM ( select tablespace_name , sum(blocks) AS sum_alloc_blocks
  FROM dba_data_files GROUP BY tablespace_name )
  , ( select tablespace_name AS fs_ts_name
  , max(blocks) AS largest_free_chunk
  , count(blocks) AS nr_free_chunks
  , sum(blocks) AS sum_free_blocks FROM dba_free_space
  GROUP BY tablespace_name ) where tablespace_name = fs_ts_name; 



    2. analyze5pct.sql


  – analyze5pct.sql
  – To analyze tables and indexes quickly, using a 5% sample size
  – (do not use this script. if you are performing the overnight collection of volumetric data)
  – 11/30/98  
      BEGIN
  DBMS_UTILITY.ANALYZE_SCHEMA (’&OWNER’, ’ESTIMATE’,NULL, 5) ;
  END;
  /



  3. nr_extents.sql


  – nr_extents.sql
  – To find out any object reaching
  – extents, and manually upgrade it to allow unlimited
  – max_extents (thus only objects we *expect* to be big
  – are allowed to become big)
  – 11/30/98
  







 select e.owner, e.segment_type , e.segment_name , count(*) as nr_extents , s.max_extents 
  , to_char ( sum ( e.bytes ) / ( 1024 * 1024 ) , ’999,999.90’) as MB 
  FROM dba_extents e , dba_segments s 
  where e.segment_name = s.segment_name 
  GROUP BY e.owner, e.segment_type , e.segment_name , s.max_extents 
  HAVING count(*) > &THRESHOLD 
  OR ( ( s.max_extents – count(*) ) < &&THRESHOLD ) 
  ORDER BY count(*) desc; 


  4. spacebound.sql


  spacebound.sql
  To identify space-bound objects. If all is well, no rows are returned.
  f any space-bound objects are found, look at value of NEXT extent
  size to figure out what happened.
  Then use coalesce (alter tablespace coalesce .
  Lastly, add another datafile to the tablespace if needed.
  11/30/98
     





 select a.table_name, a.next_extent, a.tablespace_name 
  FROM all_tables a, 
  ( select tablespace_name, max(bytes) as big_chunk 
  FROM dba_free_space 
  GROUP BY tablespace_name ) f 
  where f.tablespace_name = a.tablespace_name 
  AND a.next_extent > f.big_chunk; 

  B.每晚处理程序


  1. mk_volfact.sql


  mk_volfact.sql (only run this once to set it up; do not run it nightly!)
                  Table UTL_VOL_FACTS


     








 create TABLE utl_vol_facts ( 
  table_name VARchar2(30), 
  num_rows NUMBER, 
  meas_dt DATE ) 
  TABLESPACE platab 
  STORAGE ( 
  INITIAL 128k 
  NEXT 128k 
  PCTINCREASE 0 
  MINEXTENTS 1 
  MAXEXTENTS unlimited 
  ) 
  / 


— Public Synonym
  create PUBLIC SYNONYM utl_vol_facts FOR &OWNER..utl_vol_facts


 
  Grants for UTL_VOL_FACTS 
    





  GRANT select ON utl_vol_facts TO public 

我们一直都在努力坚持原创.......请不要一声不吭,就悄悄拿走。

我原创,你原创,我们的内容世界才会更加精彩!

【所有原创内容版权均属TechTarget,欢迎大家转发分享。但未经授权,严禁任何媒体(平面媒体、网络媒体、自媒体等)以及微信公众号复制、转载、摘编或以其他方式进行使用。】

微信公众号

TechTarget微信公众号二维码

TechTarget

官方微博

TechTarget中国官方微博二维码

TechTarget中国

电子邮件地址不会被公开。 必填项已用*标注

敬请读者发表评论,本站保留删除与本文无关和不雅评论的权力。

相关推荐