WEB开发网
开发学院数据库Oracle 创建与维护Oracle分区表和本地索引 阅读

创建与维护Oracle分区表和本地索引

 2008-08-26 12:44:08 来源:WEB开发网   
核心提示: SQL>CREATETABLEdbobjs22(object_idNUMBERNOTNULL,3object_nameVARCHAR2(128),4createdDATENOTNULL5);Tablecreated.SQL>CREATEINDEXdbobjs_idx2ONdbo

SQL>CREATETABLEdbobjs2
  2(object_idNUMBERNOTNULL,
  3object_nameVARCHAR2(128),
  4createdDATENOTNULL
  5);
  Tablecreated.
  SQL>CREATEINDEXdbobjs_idx2ONdbobjs2(created);
  Indexcreated.
  SQL>insertintodbobjs2
  2selectobject_id,object_name,created
  3fromdba_objectswherecreated
  6227rowscreated.
  SQL>commit;
  Commitcomplete.
  SQL>selectcount(distinct(object_name))fromdbobjs2wherecreated<to_date('01/01/2007','dd/mm/yyyy');
  COUNT(DISTINCT(OBJECT_NAME))
  ----------------------------
  4753
  ExecutionPlan
  ----------------------------------------------------------
  0SELECTSTATEMENTptimizer=CHOOSE
  10SORT(GROUPBY)
  21TABLEACCESS(BYINDEXROWID)OF'DBOBJS2'
  32INDEX(RANGESCAN)OF'DBOBJS_IDX2'(NON-UNIQUE)
  Statistics
  ----------------------------------------------------------
  0recursivecalls
  0dbblockgets
  2670consistentgets
  0physicalreads
  1332redosize
  400bytessentviaSQL*Nettoclient
  503bytesreceivedviaSQL*Netfromclient
  2SQL*Netroundtripsto/fromclient
  1sorts(memory)
  0sorts(disk)
  1rowsprocessed

当增加表分区时,LOCAL索引被自动维护:

 SQL>ALTERTABLEdbobjs
  2ADDPARTITIONdbobjs_08VALUESLESSTHAN(TO_DATE('01/01/2009','DD/MM/YYYY'));
  Tablealtered.
  SQL>setautotraceoff
  SQL>COLsegment_namefora20
  SQL>COLPARTITION_NAMEfora20
  SQL>SELECTsegment_name,partition_name,tablespace_name
  2FROMdba_segments
  3WHEREsegment_name='DBOBJS_IDX';
  SEGMENT_NAMEPARTITION_NAMETABLESPACE_NAME
  ----------------------------------------------------------------------
  DBOBJS_IDXDBOBJS_06USERS
  DBOBJS_IDXDBOBJS_07USERS
  DBOBJS_IDXDBOBJS_08EYGLE
  SQL>SELECTsegment_name,partition_name,tablespace_name
  2FROMdba_segments
  3WHEREsegment_name='DBOBJS';
  SEGMENT_NAMEPARTITION_NAMETABLESPACE_NAME
  ----------------------------------------------------------------------
  DBOBJSDBOBJS_06EYGLE
  DBOBJSDBOBJS_07EYGLE
  DBOBJSDBOBJS_08EYGLE

-The End-

上一页  1 2 3 

Tags:创建 维护 Oracle

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接