Oracle数据库管理员职责(四)

2016-02-19 18:46 0 1 收藏

下面图老师小编要向大家介绍下Oracle数据库管理员职责(四),看起来复杂实则是简单的,掌握好技巧就OK,喜欢就赶紧收藏起来吧!

【 tulaoshi.com - 编程语言 】

  2. analyze_comp.sql

  analyze_comp.sql

   BEGIN
  SYS.DBMS_UTILITY.ANALYZE_SCHEMA('&OWNER','COMPUTE');
  END;
  /

  3. pop_vol.sql

  pop_vol.sql 

  insertintoutl_vol_facts
  selecttable_name
  ,NVL(num_rows,0)asnum_rows
  ,trunc(last_analyzed)asmeas_dt
  fromall_tables

  or just user_tables 

   whereownerin('&OWNER')

  or a comma-separated list of owners  

   /
  commit
  /

  C.每周处理程序

  1. nextext.sql

  nextext.sql

  To find tables that don't match the tablespace default for NEXT extent.

  The implicit rule here is that every table in a given tablespace should

  use the exact same value for NEXT, which should also be the tablespace's

  default value for NEXT.

  his tells us what the setting for NEXT is for these objects today.

  11/30/98  

   SELECTsegment_name,segment_type,ds.next_extentasActual_Next
  ,dt.tablespace_name,dt.next_extentasDefault_Next
  FROMdba_tablespacesdt,dba_segmentsds
  WHEREdt.tablespace_name=ds.tablespace_name
  ANDdt.next_extent!=ds.next_extent
  ANDds.owner=UPPER('&OWNER')
  ORDERBYtablespace_name,segment_type,segment_name;

  2. existext.sql 

  existext.sql

  To check existing extents

  This tells us how many of each object's extents differ in size from

  the tablespace's default size. If this report shows a lot of different

  sized extents, your free space is likely to become fragmented. If so,

  this tablespace is a candidate for reorganizing.

  12/15/98 

   SELECTsegment_name,segment_type
  ,count(*)asnr_exts
  ,sum(DECODE(dx.bytes,dt.next_extent,0,1))asnr_illsized_exts
  ,dt.tablespace_name,dt.next_extentasdflt_ext_size
  FROMdba_tablespacesdt,dba_extentsdx
  WHEREdt.tablespace_name=dx.tablespace_name
  ANDdx.owner='&OWNER'
  GROUPBYsegment_name,segment_type,dt.tablespace_name,dt.next_extent;

  3. No_pk.sql

  no_pk.sql

  To find tables without PK constraint

  11/2/98  

   SELECTtable_name
  FROMall_tables
  WHEREwner='&OWNER'
  MINUS
  SELECTtable_name
  FROMall_constraints
  WHEREwner='&&OWNER'
  ANDconstraint_type='P';

  4. disPK.sql

  disPK.sql

  To find out which primary keys are disabled

  11/30/98 

   SELECTowner,constraint_name,table_name,status
  FROMall_constraints
  WHEREwner='&OWNER'ANDstatus='DISABLED’ANDconstraint_type='P';

  5. nonuPK.sql

  nonuPK.sql

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  To find tables with nonunique PK indexes. Requires that PK names

  follow a naming convention. An alternative query follows that

  does not have this requirement, but runs more slowly.      

  11/2/98  

   SELECTindex_name,table_name,uniqueness
  FROMall_indexes
  WHEREindex_namelike'&PKNAME%'
  ANDwner='&OWNER'ANDuniqueness='NONUNIQUE'
  SELECTc.constraint_name,i.tablespace_name,i.uniqueness
  FROMall_constraintsc,all_indexesi
  WHEREc.owner=UPPER('&OWNER')ANDi.uniqueness='NONUNIQUE'
  ANDc.constraint_type='P'ANDi.index_name=c.constraint_name

  6. mkrebuild_idx.sql

  mkrebuild_idx.sql

  Rebuild indexes to have correct storage parameters

  11/2/98 

   SELECT'alterindex'||index_name||'rebuild'
  ,'tablespaceINDEXESstorage'
  ||'(initial256Knext256Kpctincrease0);'
  FROMall_indexes
  WHERE(tablespace_name!='INDEXES'
  ORnext_extent!=(256*1024)
  )
  ANDwner='&OWNER'
  /

  7. datatype.sql

  datatype.sql

  To check datatype consistency between two environments

  11/30/98 

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

   SELECTtable_name,column_name,data_type,data_length,data_precision,data_scale,nullable
  FROMall_tab_columns--firstenvironment
  WHEREwner='&OWNER'
  MINUS
  SELECTtable_name,column_name,data_type,data_length,data_precision,data_scale,nullable
  FROMall_tab_columns@&my_db_link--secondenvironment
  WHEREwner='&OWNER2'
  orderbytable_name,column_name


  8. obj_coord.sql

  obj_coord.sql

  To find out any difference in objects between two instances

  12/08/98     

   SELECTobject_name,object_type
  FROMuser_objects
  MINUS
  SELECTobject_name,object_type
  FROMuser_objects@&my_db_link

来源:https://www.tulaoshi.com/n/20160219/1618928.html

延伸阅读
一、了解DBCC DBCC(database consistenecy checker,简称dbcc) 是一个实用命令集,用来检查数据库的逻辑一致性及物理一致性。 数据库控制台命令语句可分为以下类别: 维护: 对数据库、索引或文件组进行维护的任务。 杂项: 杂项任务,如启用跟踪标志或从内存中删除 DLL。 信息: 收集并显示各种类型信息的任务。 验证: 对数据...
在Oracle数据库中,DBA可以通过观测一定的表或视图来了解当前空间的使用状况,进而作出可能的调整决定。 一.表空间的自由空间 通过对表空间的自由空间的观察,可用来判断分配给某个表空间的空间是太多还是不够。请看下列的语句 SQL select a.file_id "FileNo",a.tablespace_name"Tablespace_name",2 ...
技巧一:把基础表与视图脱离开来。 一般来说,视图都是在基础表的上面建立起来的。也就是说,要先有基础表,而后有视图。但是,在大型数据库的设计过程中,出于项目时间的考虑,往往基础表与视图的设计是同时进行的。如一些人负责基础表的建立,另一些人则负责视图的设计与建立等等。在这个过程中,往往基础表不存在的时候,就需要建...
这带来了很多好处,但是也要求学习一些新的概念、命令、使用和管理任务。所以在投入你的生产系统之前,看看它解决什么、管理什么,以及对它的正反面评价。 为什么创建它? 回答这个问题的最好方式是直接追溯源头,Bill Bridge——自动存储管理的最初架构师。在Oracle Press标题中的Oracle ASM,Bill提供了一个链接,他在那里讨论了使用...
Oracle数据库数据对象中最基本的是表和视图,其他还有约束、序列、函数、存储过程、包、触发器等。对数据库的操作可以基本归结为对数据对象的操作,理解和掌握Oracle数据库对象是学习Oracle的捷径。 表和视图 Oracle中表是数据存储的基本结构。ORACLE8引入了分区表和对象表,ORACLE...

经验教程

51

收藏

49
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部