Sie sind auf Seite 1von 30

Managing Schema Objects

10
Copyright 2008, Oracle. All rights reserved.

Objectives

able ypes !artition IO (luster D"A as#s

After completing this lesson, you should be able to manage schema objects and: Determine appropriate table types for your requirements: heap, partition, IO , or cluster !erform related D"A tas#s:
$stimating the si%e of ne& tables Analy%ing gro&th trends Managing optimi%er statistics 'eorgani%ing schema objects online

10 - 2

Copyright 2008, Oracle. All rights reserved.

able ypes
)eap -ype Ordi"ary &heaporga"i,ed( ta#le .artitio"ed ta#le +"de*-orga"i,ed ta#le &+O-( Cl$stered ta#le %escriptio" %ata is stored as a" $"ordered collectio" &heap(. %ata is divided i"to s!aller, !ore !a"agea#le pieces. %ata &i"cl$di"g "o"-'ey val$es( is sorted a"d stored i" a )-tree i"de* str$ct$re. Related data ro! o"e or !ore ta#les are stored together. (lustered

!artitioned
10 - 3 Copyright 2008, Oracle. All rights reserved.

IO

*hat Is a !artition and *hy +se It,

able ypes 0 !artition IO (luster D"A as#s

A partition is: A piece of a -very large. table or inde/ Stored in its o&n segment +sed for improved performance and manageability

10 - /

Copyright 2008, Oracle. All rights reserved.

!artitions
(haracteristics of partitions are: Same logical attributes: Same columns, constraints, and inde/es Different physical attributes: Stored in different tablespaces ransparent to applications Several partitioning methods

10 - 0

Copyright 2008, Oracle. All rights reserved.

(reating a !artition

10 - 1

Copyright 2008, Oracle. All rights reserved.

!artitioning Methods
'ange partitioning: Maps ro&s based on logical ranges of columns values1for e/ample, months in a year )ash partitioning: Maps ro&s based on the hash value of the partitioning #ey 2ist partitioning: Maps ro&s based on a discrete list of values, provided by the D"A 'ange3hash partitioning: Maps ro&s using the range method, and &ithin each range partition, creates hash subpartitions 'ange3list partitioning: Maps ro&s first based on a range of values, then based on discrete values
Copyright 2008, Oracle. All rights reserved.

10 - 2

!artition Maintenance

10 - 8

Copyright 2008, Oracle. All rights reserved.

Inde/3Organi%ed ables

able ypes !artition 0 IO (luster D"A as#s

'egular table access

IO access

able access by ROWID

4on3#ey columns 5ey column 'o& header


10 - 3 Copyright 2008, Oracle. All rights reserved.

Inde/3Organi%ed ables and )eap ables


(ompared to heap tables, IO s:
)ave faster #ey3based access to table data Do not duplicate the storage of primary #ey values 'equire less storage +se secondary inde/es and logical ro& IDs )ave higher availability because table reorgani%ation does not invalidate secondary inde/es Must have a primary #ey that is not DEFERRABLE (annot be clustered (annot use composite partitioning (annot contain a column of type ROWID or LONG
Copyright 2008, Oracle. All rights reserved.

IO s have the follo&ing restrictions:


10 - 10

+O-s a"d 4ogical Ro5ids 6$ll 7otes .age

10 - 11

Copyright 2008, Oracle. All rights reserved.

(reating Inde/3Organi%ed ables


SQL> CREATE TABLE country 2 ( country_id CHAR(2 ! CONSTRAINT country_id_nn NOT N"LL# $ country_n%&' (ARCHAR2($) # * curr'ncy_n%&' (ARCHAR2(2* # + curr'ncy_,y&-o. (ARCHAR2(! # / &%0 BLOB# 1 2.%3 BLOB# 4 CONSTRAINT country_c_id_05 6) 7RI8AR9 :E9 (country_id 66 ORGANI;ATION INDE< 62 TABLES7ACE ind= 6! 7CTTHRESHOLD 2) 6$ O(ERFLOW TABLES7ACE u,'r,>
10 - 12 Copyright 2008, Oracle. All rights reserved.

(lusters
ORD_NO ????? 6)6 6)2 6)2 6)2 6)6 6)6 7ROD ?????? A$6)2 A2)46 G/1!) N4*1/ A*+/* W)12$ QT9 ?????? 2) 66 2) 2+ 64 6) AAA

able ypes !artition IO 0 (luster D"A as#s


C.u,t'r :'y (ORD_NO 6)6 ORD_DT C"ST_CD )*?@AN?4/ R)6 7ROD QT9 A$6)2 2) A*+/* 64 W)12$ 6) 6)2 ORD_DT C"ST_CD )/?@AN?4/ N$* 7ROD QT9 A2)46 66 G/1!) 2) N4*1/ 2+

ORD_NO ?????? 6)6 6)2

ORD_DT C"ST_CD ?????? ?????? )*?@AN?4/ R)6 )/?@AN?4/ N$*

+nclustered ord'r, and ord'r_it'& tables


10 - 13

(lustered ord'r, and ord'r_it'& tables

Copyright 2008, Oracle. All rights reserved.

(luster ypes

Inde/ cluster

)ash cluster )ash function

Sorted hash cluster )ash function

6 7 8

10 - 1/

Copyright 2008, Oracle. All rights reserved.

Cl$ster -ypes 6$ll 7otes .age

10 - 10

Copyright 2008, Oracle. All rights reserved.

Situations *here (lusters Are +seful


=orted hash

Criterio" <"i or! 'ey distri#$tio" ;ve"ly distri#$ted 'ey val$es Rarely $pdated 'ey O te" :oi"ed !aster-detail ta#les .redicta#le "$!#er o 'ey val$es 8$eries $si"g e9$ality predicate o" 'ey %ata is retrieved i" the order it 5as i"serted
10 - 11

+"de*

>ash

Copyright 2008, Oracle. All rights reserved.

Sorted )ash (luster: Overvie&


4e& data structure used to store data sorted by nonprimary #ey columns:
(luster #ey values are hashed9 'o&s corresponding to a particular cluster #ey value are sorted according to the sort #ey9

+sed to guarantee that ro& order is returned by queries &ithout sorting data:
'o&s are returned in ascending or descending order for a particular cluster #ey value9 ORDER B9 clause is not mandatory to retrieve ro&s in ascending order9

10 - 12

Copyright 2008, Oracle. All rights reserved.

Sorted )ash (luster: $/ample


CREATE CL"STER c%..,_c.u,t'r (luster #ey ( ori3in_nu&-'r N"8BER # c%.._ti&',t%&0 N"8BER SORT Sort #ey # c%.._dur%tion N"8BER SORT HASH:E9S 6)))) SINGLE TABLE HASH IS ori3in_nu&-'r SI;E *)> CREATE TABLE c%.., ( ori3in_nu&-'r N"8BER # c%.._ti&',t%&0 N"8BER # c%.._dur%tion N"8BER # otB'r_in2o (ARCHAR2(!) CL"STER c%..,_c.u,t'r( ori3in_nu&-'r#c%.._ti&',t%&0#c%.._dur%tion >
10 - 18 Copyright 2008, Oracle. All rights reserved.

Sorted )ash (luster: "asic Architecture


SI;E (luster #ey 6 HASH:E9S (luster #ey 7 : (luster #ey n "loc# chain starting points

'o&s sorted by sort #ey in each bloc# chain

:
10 - 13

Copyright 2008, Oracle. All rights reserved.

Schema Management as#s


D"A tas#s include: $stimating the si%e of ne& tables Analy%ing gro&th trends Managing optimi%er statistics 'eorgani%ing schema objects online

able ypes !artition IO (luster 0 D"A as#s

10 - 20

Copyright 2008, Oracle. All rights reserved.

$stimating 'esource +sage

10 - 21

Copyright 2008, Oracle. All rights reserved.

Analy%ing ;ro&th rends


$M gro&th trend report: +sed by the Segment Advisor Space usage statistics collected into A*'

10 - 22

Copyright 2008, Oracle. All rights reserved.

Managing Optimi%er Statistics


8 7

Not analyzed
10 - 23 Copyright 2008, Oracle. All rights reserved.

'eorgani%ing Schema Objects Online


Modifying logical or physical structure of a schema object, such as a table or inde/ ransparent to users Space requirements

10 - 2/

Copyright 2008, Oracle. All rights reserved.

Reorga"i,i"g O#:ects 6$ll 7otes .age

10 - 20

Copyright 2008, Oracle. All rights reserved.

'eorgani%ing Objects: Impact 'eport

10 - 21

Copyright 2008, Oracle. All rights reserved.

'eorgani%ing Objects: 'evie&

10 - 22

Copyright 2008, Oracle. All rights reserved.

"asic Steps for Manual Online 'eorgani%ation


69 <erify that the table is a candidate for online reorgani%ation9 79 (reate an interim table9 89 Start the redefinition process9 =9 (opy dependent objects9 > his automatically creates any triggers, inde/es, grants, and constraints on the interim table9? @9 Auery the DBA_REDEFINITION_ERRORS vie& to chec# for errors9 B9 Optionally, synchroni%e the interim table9 C9 (omplete the redefinition9 D9 Drop the interim table9
10 - 28 Copyright 2008, Oracle. All rights reserved.

Summary
In this lesson, you should have learned ho& to manage schema objects and: Determine appropriate table types for your requirements !erform related D"A tas#s:
$stimating the si%e of ne& tables Analy%ing gro&th trends Managing optimi%er statistics 'eorgani%ing schema objects online

10 - 23

Copyright 2008, Oracle. All rights reserved.

!ractice Overvie&: Managing Schema Objects


his practice covers the follo&ing topics: Monitoring table and inde/ space usage Managing optimi%er statistics 'eorgani%ing table and inde/

10 - 30

Copyright 2008, Oracle. All rights reserved.

Das könnte Ihnen auch gefallen