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

Oracle.*hat Is a !artition and *hy +se It./ Copyright © 2008. . All rights reserved. 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 .

constraints. All rights reserved.0 Copyright © 2008. .!artitions (haracteristics of partitions are: • Same logical attributes: Same columns. and inde/es • Different physical attributes: Stored in different tablespaces • ransparent to applications • Several partitioning methods 10 . Oracle.

.1 Copyright © 2008. Oracle. All rights reserved.(reating a !artition 10 .

creates hash subpartitions 'ange3list partitioning: Maps ro&s first based on a range of values. 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. then based on discrete values Copyright © 2008. All rights reserved.!artitioning Methods • 'ange partitioning: Maps ro&s based on logical ranges of columns values1for e/ample. • • • • 10 . provided by the D"A 'ange3hash partitioning: Maps ro&s using the range method. and &ithin each range partition.2 . Oracle.

.!artition Maintenance 10 . All rights reserved.8 Copyright © 2008. Oracle.

Oracle.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 . . All rights reserved.3 Copyright © 2008.

10 . 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. • IO s have the follo&ing restrictions: – – – – 10 .

+O-s a"d 4ogical Ro5ids 6$ll 7otes . All rights reserved. Oracle.age 10 .11 Copyright © 2008. .

(ARCHAR2(! # / &%0 BLOB# 1 2.> 10 . Oracle. All rights reserved.y&-o.ATION INDE< 62 TABLES7ACE ind= 6! 7CTTHRESHOLD 2) 6$ O(ERFLOW TABLES7ACE u.12 Copyright © 2008.%3 BLOB# 4 CONSTRAINT country_c_id_05 6) 7RI8AR9 :E9 (country_id 66 ORGANI. .(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_.'r.

and ord'r_it'& tables Copyright © 2008.13 (lustered ord'r.u. and ord'r_it'& tables 10 .(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.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. All rights reserved. Oracle. .

Oracle.(luster ypes Inde/ cluster )ash cluster )ash function Sorted hash cluster )ash function 6 7 8 10 .1/ Copyright © 2008. . All rights reserved.

Cl$ster -ypes 6$ll 7otes .age 10 .10 Copyright © 2008. Oracle. All rights reserved. .

All rights reserved.11 +"de* >ash Copyright © 2008.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 . .Situations *here (lusters Are +seful =orted hash Criterio" <"i or! 'ey distri#$tio" . Oracle.

All rights reserved. Oracle.12 Copyright © 2008. .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 .

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

Sorted )ash (luster: "asic Architecture SI. All rights reserved.13 Copyright © 2008. . Oracle.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 .

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. All rights reserved. . Oracle.

Oracle.$stimating 'esource +sage 10 . All rights reserved.21 Copyright © 2008. .

22 Copyright © 2008. All rights reserved. Oracle. .Analy%ing .ro&th rends $M gro&th trend report: • +sed by the Segment Advisor • Space usage statistics collected into A*' 10 .

All rights reserved.23 Copyright © 2008. 6 . Oracle.Managing Optimi%er Statistics 8 7 Not analyzed 10 .

'eorgani%ing Schema Objects Online • • • Modifying logical or physical structure of a schema object. . All rights reserved. Oracle. such as a table or inde/ ransparent to users Space requirements 10 .2/ Copyright © 2008.

i"g O#:ects 6$ll 7otes . Oracle. .20 Copyright © 2008.Reorga"i.age 10 . All rights reserved.

21 Copyright © 2008. All rights reserved. . Oracle.'eorgani%ing Objects: Impact 'eport 10 .

Oracle. All rights reserved.22 Copyright © 2008.'eorgani%ing Objects: 'evie& 10 . .

"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. All rights reserved. synchroni%e the interim table9 C9 (omplete the redefinition9 D9 Drop the interim table9 10 . grants.28 Copyright © 2008. . inde/es. and constraints on the interim table9? @9 Auery the DBA_REDEFINITION_ERRORS vie& to chec# for errors9 B9 Optionally. Oracle.

23 Copyright © 2008.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 . All rights reserved. . Oracle.

Oracle.30 Copyright © 2008.!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 . All rights reserved. .