1. Trang chủ
  2. » Biểu Mẫu - Văn Bản

Giao trinh Oracle 9

225 2 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 225
Dung lượng 2,93 MB

Nội dung

[MAXLOGMEMBERS integer] [MAXLOGHISTORY integer] [MAXDATAFILES integer] [MAXINSTANCES integer] [ARCHIVELOG|NOARCHIVELOG] [CHARACTER SET charset]. [NATIONAL CHARACTER SET charset][r]

(1)

Ng i biên so n

c Nh ng

(2)

!" #!$%& &%' ()! *

$ + , - !/ $%0

.!/ $%0 &%' (2(%3(%

! " # $ % &' ( ) * %+ , - * /0 /$ 4!$#!&%' (2(%3(%

12 % $

1- $ % " # % $

7 $ *

5 789 $%: &%' ( ;

5 789 $%: 2< = !>8 &%' ( ;

5 2(%3(% ' ' (% ! ( & ( ;

8 ! ) : 1' ;

< = ># " ' ) # ) ?

@ A ) " ' ) # ) ?

55 &%' (( $(%,%!2( ' ' (% ?

7 B 1C D

E" 9F ) D

E' G ) '

C ! ) E' '

51 789 $%: @

1 $A& '$'B'2( 5*

1 B # $A& '$'B'2( 5*

1 8C B: 6!$% D 5*

E H I J K

:4 % '& $ + " G ) K

! # L M N L0

EO B ( #F ! P #I# ; Q #2 (R )

15 8C B: $ ' 24 $%& ,'%' ($(% E!(

11 8C B: ! 2$' (, 789 $%: 55

&' #-7 6- ) @S )

T U ;

1; $A& '$'B'2( 5;

; 6- ) ;

; : &' ;

; @ D

; L ! 9+ F &' #- D

;; :V M % &' ;? % &'

(3)

; 789 $%: &%' ( '$'B'2( 1*

; , H &A!82(%2 1*

; @ # ' K

; GG K

; 0!! ' @ '! K

; @ W

; ; X Y' % # '

; , $ I J K L 78GM $%8G K,

; < ( ) Z M" 58I

; [" 58I I J

; [" 58I \ ) G # % H ; 6] # % H

;5 $A& ,'%' ($(% E!( 15

; ^ F ) " # $

; 1- $ 58 _ 6$ 9* " # $ ; E" # $

;1 2$'%$ 3+2 8$ &N '$'B'2( 1;

; E" (* 9J 'Y ;

; ?

; 6] + ` a ) b R D

; 'Y D

; ; 6] & ) " b

; ? &# ' 9J ! F c @ d

; D ef 6- '& 6- ) g ' ;K

;; L$ $%A $ !$O & '$'B'2( ;*

;; e( @ 9J' & ) " g ;K

;; < F c $ ) & '& 6- ) ( (R ) ;

;; [ # & ) " b ;

;F PG $ $! 3M > $ ;

;? 1- $ Y P =# ;

;? T h ) " b " ) $ $ ) ;

;? # $ $ ) 6- ) i > h 6] j ;

;? k ' ;

;?; G 9J 0:Cl G ;

F '$' ! $!& '%GQ3!(N2 3+,' ' (2 ;1

F '$' ! $!& '%G3+3!(N2 ;1

? @ @ ' ;

? @ @ ' Y ;;

? ! ;D

F 2$&%( ,%& ( 8%(2 3+ ,' ' (2 8C ;?

? / * ) ;D

? ' ! ' ;D

? < % ) H ;

? / * #- $ ! % ) H ' ) O! ;

? ; < % ) DBMS_METADATA ;d

? ? < % ) # m G ' ?

F5 $ $! 3M 2$&%( ,%& ( 8%(2 F

? 789 $%: & $%& E!(2 F5

? & $%& E!(2 F5

D / * ' ' G ?

D E" Z 6f ' ' G ?

D n! I ' ' G ?

D X- ) b ' ' G ?

(4)

? 789 $%: & $%& E!( F;

D &' #* ' ' G ?;

D &' #* ' ' G ' #- 6o > ` ??

D 1- $ V 6$ 9* " E' ' L ??

D T U p E' ' L ?D

?5 $ $! $%A $ ! R' & $%& E!(2 F?

@ 789 S%( & & E!(2 F)

@ 2T %( & & E!(2 F)

l ' ') G ?d

l ' :') / ' ! ?d

l ' :') # ?d

X- ) b l ' :') L i1 # j ?d

; 9J l ' :') L DK

? ! " l ' :') L % &' DK

@ N%Q & 2N!$ (2 3+ ( ,&! $2 ?*

l ' :') Q GG 9J Q %) ' ! ' :/ql D

:') Y D

E %!' D

@5 U / &A 2T %( & & E!(2 ?

[" $ (n ) ' ') G D

X 6f " l ' :') L D

[" %+ (* ' " l ' :') L D

:( " ' ') G D

@1 !M8 !" $%= 2'8 4!3#!,%! '%GV2$' BG ?5

! # $ 0lET rCm:0/m 0l/C D

E" $ ( ) * # $ 0lET rCm:0/m 0l/C D

@; J : / W $%= ?1

; ^ F ) ) D

; ^ F ) ) ' ) ' D

@F !M8 !" & 2N!$ 3+ ( ,&! $2 ?;

? s ') Y D;

? s %!' D?

? e I t " )_ 5o ) %!' D?

@? 789 $%: %( & & E!(2 ?F

D Q] ) " ' ' ') ) ' ! D?

D Q] ) " ' ' ') # # DD

D e & V ' " ' ') G DD

D X)S ) ^ F ) " ' ') ) ' ! D

D; X)S ) ^ F ) " ' ') # # D

D? ['" V ) ' ') G Dd

) 789 $%: $'B (2,' (2 3+ '$' E!(2 @*

) P8 $%0 R' '$'B'2( @*

d ) 9* " ! 9J G K

d ) )# 9* " M 9J " ' %

) , H &A! $'B (2,' (2 @

d ! u C1 9J ' v.u C1

d ! v' w vY

d #!' ! w! # !

) 789 S !' $%& $'B (2,' (2 @5

d @ ' 8v1 ) !

d :' 8v1 ) !

) $ !/$ K, $%A $ ! & $'B (2,' (2 @1

) ; $%'& X! $'B (2,' (2 !=' '$'B'2(2 @;

(5)

d; E" (* s 8h 6] #- ! ) " ;

) F $A& $'B (2,' ( @F

d? : &' ! ?

d? E 6- k " ! D

d? &' #!' ! d? E" # $ (

) ? $ 'G X! 4!3#!$'B (2,' ( @)

dD E 8h 6] #- ! J #- #!' ! d

dD 4# #* " ! d

dD - ) G d

dD 6] %+ (* G dK

dD; E 8h 6] 6- X: XC 9J LL: XC dK

dD? @ 8h " G d

dDD ! t 6y d

dD T U ! d

) @ $ $! 3M $'B (2,' (2 )5

d [ # ) ! d

d [ # ) G d

* P8 $%0 $%= )F

* &A!2( ( $2 )F

K d?

K ! ' d?

K E d?

K M d?

K ; Mv ) z d?

K ? M < ' d?

K D l' % )# dD

K #!' )# dD

K d : Q )# dD

K K : Q M dD

K X dD

K Q'' ! )# dD

* 789 S(J$( $2 )?

K EO! ! " 9J c " M dD

K ^ F ) 9J ) ! > ) " M d

K n! " 9a ) % ) ) $ ) d

*5 B & = !>8 ))

K EO B b ' % dd

K E" # $ ^ F ) % ) ) ' ) ' % dd

K ^ F ) % ) ) ' ) ' % KK

K < = '& #Z 6- ! = 6'& 6$ 9* S ) '& )# K

*1 $ $! 3M P8 $%0 $%= *

K E" Y ( ) K

K [ # ) 9I " )# K

K ) 9I " M K

K ) 9I " 9a ) $ ) K

789 S%& B' 2( ( $2 *1

!#!$ !>8 %& B' 2( ( $2 *1

7 " # K

1F 6+ ^ F ) )# K

< = '& ' % )# K;

2T %& B' 2( ( $ *;

.^ F ) ' % )# ' ) " ' K;

{ ) ( ) 6$ 9* " ' % )# K?

(6)

5 789 S%& B' 2( ( $2 *?

.^ F ) ' % )# KD

&' ' % )# K

8 6] & ) " b l' % )# K

^ F ) ' % )# Kd

; e I t % { ) ( b ' % )# K

? / # * 6- - ) b ' % )# K

D Tb8 p ' % )# K

k ' s 6- )

1 $ $! 3M %& B' 2( ( $ [ # ) ) 9I " ' % )# [ # ) $ ) %4 9I ' % )#

2 ) 9I ' % )# )

; 3P M !U 78' $#!%& B' 2( ( $

; % ) ) ' " '

; :V 6y % ) 6c ) O

; E f '

789 S$( ,&%'%G2( ( $2 F

$( ,&%'%G2( ( $2 F

< = '& #!' )# ?

.^ F ) " ' )# D

.' CM <'' D

P, , $ !' & $( ,&%'%G2( ( $ ?

5 $ $! 3M $( ,&%'%G2( ( $ @

5 82$(%2 3+! (JY&% ' !Z( $'B (2 *

5 $X 78' 3M 82$(%2 3+! (JY&% ' !Z( $'B (2 *

E K

[ # M| 9J y s E E" % h

E y s % h

5 789 S 82$(%

&'

&' T E ;

[" ) " }C ' ?

E" # $ t ' ?

; ^ 6] " E D

? ['" E D

55 $ $! 3M 82$(%2 @

[" E 9J " - % '" E d

:O8 ) - % '" b 9J " - ' ) ) d

:O8 ) ' d

51 ! (JY&% ' !Z( $'B ( 5*

+ O ) K

&' #- Mv' ) z

T (n ) l q rClL: q i J ~ ) j

:O8 ) i M ) z j

1 789 S $'B (2 51

1 $X 78' 3M $'B (2 51

< = '& "

EO B " ~ ) i 'Y j

1 !"8 = !>8 $%& $'B ( 5;

7 h 92 (* ) ;

! n! i ' ' j

(7)

7 h 1C 01< d

15 789 S $'B (2 5)

&' d

! ) " <E LlCC 9J <E W.C@ ) ' i Bj 9J E ) " ~ ) ' |!

#-; ' # ' )

? E 8h #- * )# ! #*

D e ) g & #- ) '

Q ) )'J N CM ?

11 %+ B8W [ & 2$%'! $2\ 4!3#!$'B (2 1?

lJ ) - 6$ 9* D

X wX' X D

W D

< # 8

; L' ) i l G 8j ? E %

1; 789 S !' $%= $%& $'B ( 1@

; 6] ) ( 9J # $ ^ F ) Q ' %

; EO! ! " " M \ ) i# 8j ;K

; T ) q % ;K

; c % ) ) % ) ^ F ) ;

;; #- ;

;? ['" ;

;D h# O B ) ;

; < " " 'Y # ) ' ;

1F $ $! 3M $'B (2 ;1

? ) ) 9I " ;

? ) 9I ^ F ) ' % 9J ) ) ;

; 789 S ! (J(2 ;F

; , H &A!! (J(2 ;F

; M #- ' # 9J M I ' # ;?

; W M 9J X' v M ;?

; < ' M 9J ' v! ' M ;?

; $X I ! (J ;F

; Qv lCC M ;?

; l M ;D

; Q # ! M ;

; ' " ) Qv lCC M 9J Q # ! M ;d

;5 789 S! (J ;)

; &' " M ;d

; 1- $ " ^ F ) M ?

; &' M % '" )(n i % Mj ?

; &' Q # ! M ?

; ; 6] # $ ( ' M ?

; ? EO! ! " 9J c % ) ) ^ F ) b M ?

; D [=8 s ) & il j " M ?;

; h# + n! b M ?;

; d ['" " M ??

;1 $ $! 3M ! (J FF

; [ # ) 9I " M ??

; 3# " - ' ) #- M ?D

F A, 3+$X I $%= = !>8 F@

F !#!$ !>8 F@

(8)

? X&! s ! ?

F A, = !>8 F)

? X&! \ ) :• :' ?d

? < ( ) ! "! &! DK

? ' " ! ( ) ! "! &! D

? X&! 6c ) R i< ' j D

F5 A, = !>8 B] 27 ^ &' (% ?5

? ^ F ) : •: 0@Cl D

? < # G i ! # $j D

? E' ' G i ! I % h j D;

? @ G DD

? ; E" J ! P b ') G DD

? ? E" G 6P % " DD

? D E" (* ) € % ^ F ) ' D

F1 $X I A! = !>8 B] (J,&%$ 3+! ,&%$ ?@

? E2 ) F 8h D

? E" 6- CM!' Dd

? CM!' s ! 9J CM!' ) (R ) K

F; (J,&%$ @

?; ^ F ) ) F CM!'

?; / * #- $ 6- M!'

?; E" ! ' 6]

?; 1- $ ) "' % M!' x q )• C ' • 9J E'#! ' ) ;

FF ! ,&%$ @;

?? ^ F ) ) F #!' ;

?? E 8h 6] d

? 789 S82(% )*

? 82(% $%& '$'B'2( )*

D W 9J ) J ! P dK

D @ # d

? 789 S82(% )

D E" (* s % &' #* d

D &' #* 9* M" d

D 6] - + b d

D 6] & #Z i5' j ^ F ) ! d

D ; T U W d

?5 $ $! 3M 82(% )1

@ 789 S$ $! ,%&E!(2 );

@ !#!$ !>8 ,%&E!( );

@ 789 S,%&E!( );

&' < 'G d;

! " ) * & 9I J ) 84 d?

/" < 'G ' W dD

ef ) * & J ) 84 dD

; 6] ) ' ) ! 'G d

? T U ! 'G d

D ) 9I " ) * & J ) 84 dd

@5 789 S K$ C8 ))

&' ! 'G k # % H KK

E" # $ I t # % H KK

1- $ 6f h# + ' ) k # % H K

TJ# ) O! # % H ' )(R ^ F ) K

; ) 9I # % H K

(9)

) , H &A!78GM *5

d E" 58I $ ) K

d /" " 58I $ ) K

d [" \ ) ! Y' G K

d ) 9I " 58I K;

) 789 S78GM *F

d c " 58I $ ) K?

d 8I " 6$ (n ) KD

d /" " 58I 6$ (n ) KD

d ) 9I " 58I KD

d ; c " 58I 6$ (n ) K

* 789 S I ' [%& (\ *)

* I ' [%& (\ $%& '$'B'2( *)

K E" + O b Z Kd

K :n + b ^ F ) Z Kd

* 789 S I ' *)

K &' 9J ^ " E Z Kd

K E" Z 6(n ) g ` K

K ^ " Z

K /" " Z

K ; ! Z #f

K ? C 9J @ " Z K D c " Z S " K ['" " Z

*5 $ $! 3M I '

$_ ` a $%b = 784 !' ;

6 = 784 !' ;

E" 6f h# + ;

E y ! %+ s ' ;

! %+ s 9J ! %+ s 5$ ) b ?

$ ' 24 ?

:s y # $ D

X)2 ) ! F - 9J ) " ' #f D

[" " #2 (R )

E t 6f ( ) )2 ) i: ) ) v@ ! j ' S ) ' d

; # $ X: 9J " J# : d

5 $ $! 3M ! $%: b <!$A& ) 9I ! %k s ^ F )

2 ) 9I " ! ) $ X:

,

(10)

Ch ng CÁC I M M I TRONG ORACLE 9i

< d l idK j 6(n 6( (R ) 9J' 6P {# KK 9J 6(n • ] ) 4# #- $ Z { )• 6f h# #* E" 6f h# J8 6o J# ' k

4 #I# ‚'• '& 9J @(* 6=8• ƒ M # M| #- $ 6f h# #* J8x

f gf hi jk lm n o pk kqlr hk l r

E Z { ) J8 6(n ) O! ' ) )> ! % ) DBMS_REDEFINITION ' ) O!•

' ! |! )(R a ) > h ) g & O B b #- ) = @1: ) % > ) ' r* " ! (* • • „ ) > h ) g & O B b

( ) (* 6> P ! 6f 6- 'GG ' > e I J8 % ) '

f gf s t lt ANALYZE VALIDATE STRUCTURE u v

E> h s ANALYZE 6h $ ( ) % ) > @1: s

w x y lz { k

) O! I % h Y ) 6$ 9* " ' ' ') ) ' ! s ' R

) itime-basedj ' ) O primary/standby• O " ' ') & ! #

ƒ 6(n ( c 8h * r J8 ƒ % & $ (n ) " ' '

$m| r }k kqk r

d ) O! Z { ) suspend/resume ^ F ) ALTER SYSTEM

SUSPEND6h &# ' • S ) #y ' " M O 9J' 6$ 9* " G 9J ' ' G & ) " &# '• " ' " 9J' iI/O operationsj ) s

ƒ 6(n % B 9J ) ! 9J' #* ! " ƒ 6(n 6H8 9J' s ALTER SYSTEM RESUME6h % ! F & & ) (R ) b

~ • h€ m h€ j }k kqk r

d ' ! |! 6( 9J' 6- '& 6- ) g i5 j ' 6> t > " @Q0 ' • • 9J " <:w : J 6(n ! |! s & ) " J8 ' ! |!

)(R a ) s " ' " #- " 'J s F ) = ALTER SYSTEM QUIESCE RESTRICTED6h 6( 9I 6- '& 6- ) g

• ‚ x ƒ f „ nf f lm x ƒ k

ƒ s 6- ) s &# ' i ! )j 9J 6> % ! F i # )j & s " ' " $ %|# i ) '! ' j ' ) (R ) n! > V O! ! " % ) ) X R #J ƒ > h s s " ' " n! k 93 9I ) "' V ( " ! (* % " V J8 6(n % _ ! F

& 6(n s 6- ) % ! F (R )

f gf lz { w h… lz {

.$ (n ) 6+ ( $ #J > h ^ F ) 6h ( " ' ' ') 6(n { ) S ; * K

$s h€ † • l‡ ˆ x ƒ k

d ' ! |! k s 6- ) ) ! > ) 9J ^ F ) " 9a ) % ) ) > ' ) " )# 6(n ( ' ) " ' # ) ! ) ^ F ) # 6I SEGMENT SPACE MANAGEMENT > ' ) = CREATE TABLESPACE > h ^

(11)

‰f ‰ lm l qkl }rŠr |‹ x s t k q• fk

' #f • > h > #- 9J ! P b #- ) 6(n ! = % i! ' j & ) " % ) ^ F ) i6" O UNUSABLEj ƒ 6(n &! 9J' ' ) ) ' M rJ P M=8 s ) & i j 'J - ) ' M d ' ! |! s s 6- ) )

J8 ) # 6I UPDATE GLOBAL INDEX > ' ) = ALTER TABLE% s '

f gf Œ }„ h• v w x… Ž ql x

' ! |! ^ F ) 6c ) R I %+ , ' % i# ! ' % z j 7+ (* H i ' % zj 6(n 58 ' ) # $ % &' DB_BLOCK_SIZE ( ) „ ) > h # - ) 4# ) " %+ (* ' % ! H i ' ' % z j E" %+ (*

' % ! H 6(n t … #V % &' ! 7+ (* ' % H 6(n ^ F ) '

SYSTEM ! 9J P " ! % " r V n ^ F ) I %+ , ' % ƒ

' ! |! s ' 6] " ! b " #J % ) > a ) #- %+ (* ' %

7 • l‡ h€ q ••r k r

7+ (* b GG > ' ) 9a ) * # / ' 6(n k 6- ) e I J8 > ) g J ) " b # $ DB_BLOCK_BUFFERSi ' ) G # $ % &'j > h 6(n

8 ) " > ' ) # $ % " • # $DB_CACHE_SIZE ' ) d• GG

& 6(n ! = J I - # ' i j > ^ F ) 6- # ! ' % z Q$ ) " %+ , ' % 6(n t ' ) # $DB_ nK_CACHE_SIZE ( ) Z )

7 • l‡ h€ ˆ • '

E" # $ % &' > h " 6- ) * %+ , b 9a ) * /0 rJ > h 6] %+ , b /0 A J ) ) = ALTER SYSTEM SET

7 • l‡ t x ƒ f „ [ } \ s h€

^ F ) ' % )# 6h ( " ) ' % ! F r ! F c i 'j ' )c# ' %• '• 9J 6] i ) j 6$ 9* #V % P d ' ! |! &' ) #- ' ! 6h ( " ) ! F c J8 r ^ F ) '

! ƒ J# ) # * + ! Z &! b 9a ) % ) ) ' % )# • 9J ' ! |! ! F c & " ) J #J % ) n a )

7 • l‡ •lr & k lr

1- h# #* ' ) d J k G ) " # $ % &' DB_CREATE_FILE_DEST 9J DB_CREATE_ONLINE_LOG_DEST_ n > h t ' $ )

" 6(R ) € F h ( " G - ! • ' ' ') G ' ' G # ' k G O ' ) $ )

$s h€ Š }k k•lr

d ) O! #- s y ' ! |! s 6- ) M'" p i #'9 j " G #V % ! ( ) Z ) U ) = DROP TABLESPACC † y ( ) s ' ) = ALTER DATABASE TEMPFILC „ ) 6(n ^ F ) 6h M'" " #!' G ( ) Z )

rk}k k ',!

1- PL/SQL ! % ) #* • DBMS_METADATA.GET_DDL• 6(n 6( 9J' d ' ! |! O8 6(n " i# j N E" ) ] ) n! 9I " # ' ‡

q• Y (Šr kl kqlr

d ' ! |! ! ' % h t 6y " ' ) " ) )'J i M j CM J " #J % ) \# ' ) • 9J > h " % & ) iG' # j J' 6> E= CREATE TABLE ORGANIZATION EXTERNAL 6(n ^ F ) 6h

(12)

ORACLE_LOADER• 6> ) O! % { ) " M& ( ) Z ) 9* B ! "! ' ) ' ' G

$‚ zv k

^ F ) # 6I USING INDEX ' ) = CREATE TABLE ALTER TABLE 6h ' ! |! t … M #V % ^ F ) J ) - % 8 ! # % 4# 9J' 6>• „ ) > h ){ U i '!! )j

Elr k| ‘ r r

( " # $ % &' ' ' ' ) G # $ (* % & ) 9{ 9J 6(n 6f & " #

E" # $ % &' b \# ' ) G # $ (R ) % & ) ! = 9J > h 6(n ( ' )

$r|f k kqlrfk r|~ hi

E> h 4# 9J' # #* DEFAULT TEMPORARY TABLESPACE 9J' = CREATE

DATABASE 6h ' ! |! &' #!' ! ) ' ) R ) &' !

J8 ƒ 6(n ^ F ) ( #!' ! #f

~ k k

' ! |! )" ' #V #- ' b ' O > + ' ! = ) # h P# € ) " '

€ ‘ k h’ & k lr k kqk r • k ' k

@ E' G ) ' > #- $ 6] ' ) % ' 6>• > ) O! " #€ i #! j ) B! ' % #• ) # * ) g " ' ‡ ' )

X)(R a ) „ ) > h &' " #€ J8 ) ^ 6] " #€ > ` &' \ ) ) F @ E' G ) ' „ ) > h 4# 9J' ) 'f 6> " % #€ )y J " ˆ Y #! # X ) # J8 J ) 9+ F J

' )

7 • l‡ t Œ }„ }rŠ

4# # 6I MONITORING USAGE 9J' ' ) = ALTER INDEX 6h > h M" 9J k M % > 6(n s

t x f “ ˆ

d) * ^ F ) %4 " ! = 9a )• > ' ! |! t #- " " ) " R & ( ) Z ) 9* " ! ' ) ' # b #V ! = 9a ) < ( ) Z %4 ! = 9a ) i ! ' ) # ' j 6(n 6( \# #F 6+ #2 '" ! = " 6$ 9* " ) " R & r J8 % > s 6(n \ ) " ! ( ) ! "! ) ! ' ) i! = % ' % ' ) ) " j ! ' ) i! = % ' J# {#j

, “ x r | q‚| }rŠY k ”r} kqlr

d ' ! |! ^ F ) ! ( ) ! "! {# % ! = % " Mv' ) z ‰ "

! (* • ! = % ' Mv' ) z 9€ s 6(n ( ) t \ )

! ( ) ! "! ) # '

JŒ l‡ •q † r rf r l m

(13)

y| |• k kqk r%r r k k r

E> #- $ Z { ) #* 6(n 4# 9J' @ l ' ) x

E> % { ) &' #- ' !'' • J ( Z 6(n #- $ (n ) * O " ' 6c ) R ) 6(n s X > I $ (n ) * O " ' a ) 6(n s " ' #* J8 ƒ 6(n 6( 9J' J ) 6n 6h R s „ ) > h 6( #- % ' ) R ) A i # ' j 6h ' ! |! s U s " ' #* ] ) J8

s 6- ) 8h S #- ># J8 ) #- ># % " † ' s I t b i # ' j X #- ' 6(n &' # # - #- >#

J' 6> s ' ) % ' ) R ) J R ) ' ! |! ' 6> > h 6(n s 6- ) 8h ) #- ># % " 9* ) 84 P J ) 84 % "

E> % { ) ){ f s " ' " #J 6(n s % J ƒ ! &8 ' ) #-R ) J J % ' ) R ) ' ! |!

E> % { ) &' #- ' !'' • J Z #- $ (n ) O 9a ) % ) ) J ' % ! F ) i 'j

– • Š s v Š s i< 'M8 ' ' z ' j

d ' ! |! #- \# *! ) i# v j M" - #- > h s J8 \ ) " 6( 9J' # 6IGRANT CONNECT THROUGH ' ) = ALTER USER „ ) > h t … ~ b *! ) i# j ' ) % $ *

'ffl k lr

' ! |! )" ' ' " !! ' #J 6(n %+ '& \ ) " ^ F ) <:w : ! % ) ^ F ) # 6I IDENTIFIED USING ! % ) ' ) = CREATE ROLE

(14)

Ch ng CÁC THÀNH PH N KI N TRÚC

2.1 KI N TRÚC ORACLE SERVER

9 J #- $ ) 6$ (n )v5 ' ! |! k )

#- " 'J ' )c# J ! P + J 9J

2.1.1 Oracle Instance

' )c# #- O B - * r| l qkl ' rk [2 '\ 9J "

qk x } f r r [ • w \6(n ^ F ) 6h

6(n M" # $ #2 (R )ORACLE_SID b I J

T3 9ƒ B

System Global Area - SGA

./0 J 9a ) - * ‚ 6(n ^ F ) 6h ( 9J " ) I % h b

9 /06(n O! ! " i ' j ' ) - * b #"8 + #J ) '& 6- ) 6> E" W % $ * ƒ ‚ " > ' ) /0• # - ) % ) ) - * ' /0 ƒ J# = ) ' O b $ )• ( 6(n I ' ) $ )

6c ) R ) # h " ' " M O 6g i % wj /0 ' )c# #- 9J O B - * + x

!'' x :J #- ! P b /0 ( " O B - * ‚ @ GG x :( " 6(n ^ F ) )P O

l ' ') GG x e(n ^ F ) ' ~ 3# & " 6c ' ) 9J 6(n s " %) ' ! '

eh • ƒ M # M| F h S ) J ! P k r, l

!'' J #- ! P ' ) /09J 6(n ^ F ) % s ! = + = i! ! j 7+ (* b !'' 6(n M" # $ SHARED_POOL_SIZE > ' ) ! # G iG # $j

(15)

T3 9ƒ EO B <''

q k k r

: ( ) 9I " = : 6(n ^ F ) )P O ' )c#x X- ) b = & ) M i9{ j

< i =8 ! = + j 6(n M=8 s ) † - 9J' =

CM ' ! i 6c s j )c# " (* s 9J $ (

@' " ) 6o 6(n ( ' ) : % s & #- = 9O • (* % s = • ! ' ƒ O8 & " ) 6o 6(n ! = + #J % ) ! ! = + & = @' 8• : > h ) B! = ) ' O s

k k k k r

@ ' J #- J ! P b !'' ( ) b '

6(n ^ F ) )P O ( " ) g " )• ) g " - • # • ! Y' • 9J " ! ) i58I j

' ) ) 6'& ! = + i! ! j• ! ' ƒ 3# " ) ' ) ' 6h M" " 6$ (n ) ' ) = : 9J 6h M" " #Z 58I ( ) Z ) ' ) (R ) n! P • ! ' > h % &' 9J &! " ) S " G

k k q ••r k r

7 s #- 9O • ! ' ƒ 3# " ' % P ' ) GG X % ) 3# O8 ' % ' ) GG • ! ' #* 6y " ' % S G 9J &' #- ' b ' % 6> 9J' ' ) 9a ) * # i GG j X ( 8• 9* "

P M O * ' % 6> J8 ƒ % ) P ! M O 9J' G

T3 9ƒ @ GG

@ GG J 9a ) * ' ) /0 ^ F ) 6h ( " ' % 6(n ^ F ) )P O ( ) s ( %+ (* b ' % 6(n M" # $ DB_BLOCK_SIZE, %+ (* b 9a ) # ' ) GG „ ) 6(n M" # $ DB_BLOCK_BUFFERS

(16)

%r} l q ••r

! ' ) & " 6] b #- 9J' ' ') GG • 6=8 „ ) J #- ! P - * /0

T3 9ƒ l ' ') GG

E> #- $ 6f h# P =# b l ' ') GG x 7+ (* 6(n M" # $LOG_BUFFER

:( " ' ' i ) c ! F j #V % > 6]

l ' ') GG 6(n ^ F ) #- " (R ) M 84 9J " 6] #- ' > h \# M 9* " 6] b " ' % "

Q- # 6(n ] Z ' % h GG i - # $ 9~ )j Z J 6] ƒ ! F 6(n &! 6P % 9a ) # 6o 6(n ^ F )

Background process

Q %) ' ! ' i " I j s " Z { ) ' R )y M^ k ( ) Z ) X> I % h 9J' • ) O! " M^ k ' ) ' ) = ) ' 9J

a8 ' S ) O #J > " Q %) ' ! ' (x @ q iDBW0jx / & " 6] ' ) GG " G

:') q iLGWRjx / & " 6] 6(n 6{ ) %k ' ) ' ') GG 9J' " ' ') G

.8 # 1' ' iSMONjx h# s O 5" ' )

< ' 1' ' iPMONjx @y Š! & J ) 84 % " b )f! V

E %!' < ' iCKPTjx E ! & & ) " b ) ' ) G I % h 9J G #V % > 6] ' ) GG

k kqk rN r [ BN*\

(17)

T3 9ƒ ; @ q i@Qqlj

r* ^ F ) J8• O ^ F ) ƒ 6(n ' ! ' t &' " 6] GG •DBWR) 9J' " G ' * % x

.$ (n ) GG 6" O 6& * ) " )(, )

3 O GG #J 9€ % ) 3# O8 ( ) Z ) " R ) 58

N r

:') q iLGWRj J #- ' ) " %) ' ! ' > " # k ' ') GG 6h ) & " ) ' ) l ' ') GG 9J' l ' ') G l ' ') GG J - # 6(n ] Z ' % h $ 9~ )

T3 9ƒ ? :') q i:/q j

LGWR) & #- " P s 9J' ' ') G ' " $ ) x ' ') GG 6P8

7 M # ' i ) (R ) J ) =8j

(* % DBWR) & " ' % 6] ' ) GG 9J' " G

7 '## #- '

2 r| [2 & \

3 # #' ' iSMONj s ! F c " s $ i '9 8j ) & R h# 6(n % 6- ) i !j• P SMON „ ) > " # y Š! " #!' )# % ) ~ 6(n ^ F ) ' ) ' 8v# ) ! SMON % ! F & " ' #V % M s $ SMON 6I 6f s % h# 9J % _ ! F " s $ % P

' ) #2 (R ) < •SMON! ' b #- > h s % ! F ' ) (R ) n! E<W b #"8 + 6> )f! s $

, r [, & \

3 ! ' #' ' iPMONj s ! F c #V % > #- ! ' )f! V

(18)

) ! > ) " ' % ) J8• 9J U p ! ' @ b > % p " " ! '

PMON % h# & ) " b )^ i ! j 9J " ! ' • % 6- ) & i j #V % M s $ PMON „ ) ~ s 6{ ) %k " ) 9I 9J ! ! ' 9* Y' %

( ) s (SMON•PMON6(n )y #V % M s $ ' ) $ ) r xf , r [ ,$\

E ! & & ) " b ) ' ) G I % h 9J G #V % > 6] ' )

GG [ %!' % :

O " ' ) GG 6o 6] + ' R h# %!'

ƒ 6(n %) ' ! ' @Qql ) G

Q %) ' ! ' E7< ! ! P b " G 9J " ' ' G

E %!' > h M 6$ 9* O " G ' ) 'f „ ) > h M 9*

#- G F h

E %!' M ' " $ ) x 1V % > ') Y

7 #- 'Y #- 9* " 6- S 6- '

[ ' ( R ) 58 ' ) " # $ % &'

LOG_CHECKPOINT_INTERVAL9JLOG_CHECKPOINT_TIMEOUT > 84 P s ! b

2 ) 9I %!' 6(n ( ' ) G ' ) (R ) n! " # $ % &' LOG_CHECKPOINTS_TO_ALERT6(n 6f JTRUE rJ )(n & 9* ) " FALSE

2.1.2 Oracle database

J ! n! " 6(n M # ( #- J ! P iW j @ > # 9F ( 9J 9I " ) @ 6(n M # M| (* )> 6- O B

') 9J O B k 8• O B J8 9€ c & " • k

' O B ( k % ) )=8 ( ) * O B ')

6(n M" #- O 9J 6(n 58 ' ) # $ @QmX01C b ! # G

(19)

C u trúc v t lý database

EO B k ' )c# ! n! " ' ' G • ' ' ') G 9J " G x k k•lr

1V #- 6I > h > #- I G E" G Z 'J

- ' ) E" - O B ') b ( M

6I 6(n ( (* & ) k ' ) " G b 1- $ + O b G x

1V G t > h 6(n ^ F ) ' )

#-Q4 & 6>• G „ ) ~ > #- $ + O ' ! |! s 6- ) # - ) %+ (*

#V % V (

1- I G &' #- ( ') b )y J !

1- G t - 9I #- !

@ ' ) #- G > h 6y 9J ( 9J' 9a ) * - # b r+ Fx %

#-# $ ! ' ) #- - ' ) (R ) n! ) 84 P

% ) > ' ) # #' R • > ƒ 6(n 6y s ! S " G 9J ( 9J' ' ) - *

8 • ] ) 4# #* 9J' % ) O ! ) ) 9J' " G E" > h &# R ) 9J' - * 6h ) # h M O * - * )'J i] 6g j J# { ) { ) ^ F ) $ ) E2 ) ) J8 6(n s @Qq

%) ' ! ' %r} Elr

1V 6I > #- ! n! S K ' ') G E" ' ') G ' ) (R ) 6(n )y J ‹ ' ') 1- ' ') 6(n &' J S I ' i)y J " ' ' j

E Z { ) + b ' ') J ) & O " 6] 6$ 9* ' ) l ' ') G 6(n ^ F ) 6h ' % p ) p ) > ' s $ ' ! |! ^ F ) a ) #- B I ' ') )y J # ! M ' ') 6h a ) ( " ' b ' ')

4 " ] 6g % "

E" ) ' ) ' ') G t 6(n ^ F ) 6h % ! F & ' ) (R ) n! $ ) )f! s $ 9J % ) ' ! |! s ! ' ) " G ' )

r+ Fx % > s $ M ( #O O n Œ ) & • " ' ) - * % ) h ) s ! " G 9J )=8 (n ) #O • O "

#O J8 6I > h % ! F & ) % 6(n # & r J8 > h s 6(n ) ^ F ) ) + " ) #* O > ' ) " ' ') G - G ƒ % ! F & " ' R h# (* % M s $ E2 ) % ! F S " ' ') 6(n )y J ' ) G' Y

l Elr

1V 6I > + O #- ' ' G E' ' G Z " #F ) 58

O B k b (x

4 b

4 9J ( " G ' ') G # #! i#$ R ) j &' ! •

1V % J' #- b 6(n # • ' ' G b > ƒ 6(n ^ F ) 6h M" G 9J " ' ') G %•# " J ! P k 6] i9+ F

(20)

C u trúc logic databse

EO B ') b ' )c# " 6$ (n ) ! • # ' ‡ •

' % • M • 9J )# $kqlrfk r

1- > h 6(n ! = 9I #f ') J " )y J " ! • ! (R ) ' )c# #- ># " J ! P > ') 9*

k kqk rQ$kqlrfk rQ k k•lr

1$ ) " • ! • 9J G > h 6(n # '& 9ƒ x

T3 9ƒ ) • ! 9J G

E> #- $ h# P =#x

1V > h ! = 9I #f ') J #- I !

1V ! > h 6(n &' • 9I #f k• #- 'f I G

7+ (* b #- ! \ ) ] ) %+ (* b " G b > r+ Fx ' ) 9ƒ u C1 ! > %+ (* J 1Q ~ W.Cl ! > %+

(* J 1Q

7+ (* b „ ) > h M" 6(n \ ) ] ) %+ (* b " ! b > r+ Fx ' ) 9ƒ %+ (* b J ?1Q r|k r|k &q•r

# J ! n! " 6$ (n ) i' ‡ j > ' ) # ' ‡ J " O B ')

' ! |! # s ! * ' ) # ' ‡ ' )c# " O B

( • Y • • ' ! ' • ' 8# • M • • 9J %

k k Bl x Q(Šr Qk } 2r |r

6 h % h % ) ) ( 6g Z ) ' " O B ') ' )c# " ' % • M • 9J )#

& k lr k k Bl x

:J #Z ! = O! ') O! O • " b 6(n ( ' ) " ' % 1- ' % ( ) Z ) 9* #- $ (n ) O " k b ' ) % ) ) 6g Z ) 7+ (* b #- ' % 6(n t ' #V ) %

6(n &' ! @ ^ F )• O! ! " 9J ) ! > ) 9a ) % ) ) ( )

5 " ' %

(Šr

:J #Z ! = ' 9I #f ') " 9a ) % ) ) ' ) 1- M ' )c# #- $ ' % ! • a ) 6(n ( & #- ( ) CM 6(n ^ F ) 6h ( " ) > a ) % h

(21)

:J #Z ! = ' 9I #f ') " 9a ) % ) ) ' ) 1- )# J #- ! n! " M 6(n O! ! " ' #- O B ') )# > h 6(n ! =

' I '& % " x

@ )#

1V #- ' v > #- )# E" ' ) #-6(n ( ' ) " M - )# 6> r* #- ! '

3 #V ! ' & ( ) Z ) 9* #- )#

1V E ( ) Z ) 9* #- )# @ b O " ' )

6> 6I 6(n ( ' ) )# - E 6> M

)# 1V #-! ' M 6IM #V !> #- ' M„ ) & ( ) Z ) 9* #-)# ( " Mb )#> ' )

' % )#

1- 'f I ' % )# b 6(n &' ! )(R 6h ( " ) ) ! F 9F ' % ! F E" ) ' ) l' % )# 6(n ^ F ) 6hx

&' s 6c ) O " ) 6y 6(n S ^ F ) ' ) 5" % ! F

< F c & " ) ' ( '## 6$ 9* #V

#!' )#

#!' )# 6(n s 6- ) &' #V % #- = : # P #- 9a ) * ) ) 6h s " ) b #3 ( _! M ! % B = 6>• " M - #!'

)# ƒ & 6(n 'J ' $ )

s O! ! " 9a ) % ) ) ( #- " '& #V % " M O! ! " 6o ^ F )

Các c u trúc v t lý khác

X)'J • ~ ^ F ) " G % " 6h ( ) E" G 6> ' )c#x < # G x < # G t " # $ 6(n ^ F ) ' ) X)(R

> h ^ 6] #- 9J ) > ' ) G J8 E" # $ ' ) ! # G 6(n & ) 9{

< Y' G x [" 58I b S ) ' ) E ' ! |! )(R ^ F ) % 6- ) 9J _

#-0 ' ') G x :J 'GG b " ' ') G Z " ) P 6h ! F c

2.1.3 Qu n tr c s d li u Oracle

J ) ' 9J J 6h > > h ! 9J M^ k 6(n O " 84 P i j S ! + E eh J# 6(n I J8• )(R

P ! h 6(n % B b

2.1.4 Thi t l p tham s kh i t o nh h ng t i kích c b nh SGA

# $ % &' ( ) * %+ (* - * O! ! " ' 9a ) # / ' X)'& S # $SGA_MAX_SIZE• ~ & " # $ % " 6I J # $ 6- ) Z J > h 6] ) "

b B ) ) ' ) B ) &8 ) = ALTER SYSTEM 7+ (*

b /0 „ ) > h 6] 6(n ' ) 5" &8 $ • l‰f k| ‘ B ••r k r

# $ % &' GG 58 %+ (* b GG J #- ! P b /0

^ F ) " # $DB_CACHE_SIZE 9J #- ' ) ) # $ DB_nK_CACHE_SIZE6h '

(22)

6 ' # $ DB_CACHE_SIZE• ~ # $ DB_nK_CACHE_SIZE ƒ 6(n )" #f

\ ) K

7+ (* b GG ƒ > ( ) I * O s b $ ) 7+

(* J ) * J ) ) # * 6y 9J ) 6g • %+ (* b * ƒ $ I - * 9J ƒ > I $ %|# ' ) s ! ) ) i! = )j Y !! ) i ' 6] j - *

$ k| ‘ B— ' (—2!Z(

# $ % &'DB_CACHE_SIZE6(n ^ F ) ' # $DB_BLOCK_BUFFERS b "

! (* % # $DB_CACHE_SIZE 58 %+ (* b ' % GG H

7+ (* b #- ' % H & 6(n 58 ' ) # $DB_BLOCK_SIZE

8 8• # $ DB_BLOCK_BUFFERS 9€ 6(n ^ F ) 6h ( ) + 9* " ! (* •

8 ) " b > % ) 6(n ^ F ) ' " # $ 6- ) $ k| ‘ B—n.— ' (—2!Z(

E t %+ , J - $ ) 84 P %+ (* b ' % GG X> 6(n t " # $x DB_2K_CACHE_SIZE

DB_4K_CACHE_SIZE DB_8K_CACHE_SIZE DB_16K_CACHE_SIZE DB_32K_CACHE_SIZE

1V # $ t %+ , b GG ( ) Z ) 9* %+ , b ' % r+ Fx

DB_BLOCK_SIZE=4096 DB_CACHE_SIZE=12M DB_2K_CACHE_SIZE=8M DB_8K_CACHE_SIZE=4M

‰ 9+ F J8• " # $ t %+ (* ' % H b J 7+ (* ( ) Z ) 9* %+ (* ' % H J E" %+ (* # - ) b J 9J ƒ 6(n 6f

& 9* ) " ( ) Z ) J 9J w ˜ x… Ž pk k r} , l

# $ SHARED_POOL_SIZE ' ) ! d J # $ 6- )• Z J > h 6]

6(n ) " b > i6 I J8 % ) h s 6(n ' ) " ! (* j X> ' ! |! 6] %+ (* b !'' J #- ' ) " J ! P b /0 ' #f

„ ) y #- ) " #f ! a n! ' # $ J8 w ˜ x… Ž pk k r, l

( ) s (SHARED_POOL_SIZE, # $LARGE_POOL_SIZE „ ) J #- # $ 6- )• > '

! |! I t %+ , b ) !'' • 6=8 „ ) J #- J ! P ' ) /0 • m x… Ž pk '

# $ SGA_MAX_SIZE 58 %+ , * O b # / ' „ ) > h

6] %+ , b GG • !'' 9J ) !'' • 6] J8 J # - ) ) " %+ (* ' " J ! P b /0 / " # - ) 4# J8 „ ) % ) 6f *

)(, ) b SGA_MAX_SIZE

' ) (R ) n! % ) t … ) " b SGA_MAX_SIZE ƒ s 6- ) )" ) " J8

\ ) ] ) $ %+ , b " J ! P b /0 B 6P

(23)

2.2.1 Mơ hình k t n i

E" E > h % $ * ) K " x

7 $ s !x % $ #J E \# a ) #- #"8 b

7 $ *! i Y'v j v x E \# #- #"8 + % " 9J % $ s ! * #"8 b

7 $ *! i v jx E \# #"8 + % " 9* #"8 b • > ) ' ! 9* #- Z ) F ) #- #"8 b #& ) i Y' % j 9J I % h Z ) F )

8 #"8 b J8 % $ *

T3 9ƒ d $ *

2.2.2 M t s khái ni m c b n liên quan n k t n i

Connection (liên k t)

: % J 6(R ) & ) #- ! ' 9J #- ' ) (R ) n! ^ F ) " '' 'f " Z ) F ) ) a ) #- #"8 9* • 6(R ) & ƒ 6(n &' ! ) #"8 6> ' ) (R ) n! \# #- #"8 % " % ƒ ^ F ) 6(R ) #& ) 6h % $ *

Session (phiên)

1- ! ( ) Z ) 9* #- % F h b #- * #- < _ 6P % % $ * 6o 6(n % h# n! 9J % B % s ') ' % p

'f % B #- " O (R ) 1- a ) #- B > h > I ! J# 6h % $ * ) " Z ) F ) " '' % " r+ x W > h 6c ) R > " ! J# ) :•< • @ '! wKKK L' #• *

:( kx < t &' ! 6(n % 6o ` J ) ' % $ b "

2.2.3 K t n i t i database

Các b c th c hi n k t n i

eh % $ * (* • P ! &' % * : % * 6(n &' ' " (* x

W ^ F ) ) F :•< ^ F ) " ) F % " b ( @ '! wKKK L' # 6h % &' ' ) #2 E v • " ) F Z ) F ) J8 6(n &8 #"8 E

W s ') 9J' 9* % "' # • ! Y' 9J 4 % * E" Z ) F ) '' ƒ &' #- 6h % $ * "

(24)

Ví d th c hi n k t n i t i database

eh h … 9I " (* s % $ • o8 M # M| #- 9+ F #2 % $ * s #- & #- #"8 + % " > % $ * #"8 + #J

9 ) &8 6> r % $ 6(n s ) 6(R ) #& ) \ ) " ^ F )

9F X

1 & #"8 b• P # ' ) &8 9J ` J ) 6> " + S ! + E 1"8 b J8 6(n )y J '

2 & #- #"8 &# > &8 " Z ) F ) i)y J ' # Y' % ' j ƒ

s " ! ' 6h % $ * E !! ' s !

#-% $ * ) X

3 1"8 b 6> > " X ƒ s ) 9J ~ 3# O " 84 P )^ S ! + 9J 6> ƒ &' #- ! ' ( ) Z ) 9* ! '

4 s #- = : '## #- ' r+ F (

4 #- ~ ) ' )

#-5 ! ' ƒ 9I = )^ * S E • % h# 9J ! = + = • J8 6(n s ' ) !'' ! ' 6>• ! ' ƒ % h# 58I

! b

6 ! ' 9I " ) " 84 P S " > ' ) G ' ) # ) '

7 ! ' 6] " > ' ) # ) ' @Qq ! ' ) & " ' % 6o 6] ] 6g LGWR! ' ƒ ) & ) ! Z " ) 6] 9J' ' ' ') G ) % ' 6(n '##

(25)

Ch ng CÁC CÔNG C QU N TR ORACLE

3.1.CÁC CÔNG C QU N TR C S! D" LI#U ORACLE

& 6o ) O! O I ) F ' ! |! E> h %h 6=8

#- $ ) F x

ƒ „ ™ •

) : 1' E2 ) F ' 6- ~ ) (

i% 6- )j• 'Y i S )j •

:•< : 1' e=8 J #- + ^ F ) ' ) ( ) !• ) 'Y • 'f ! F c

C ! ) :J ) F > ) ' 6c y 6h s • I % h 9J 6] #- 'f I

:•:' + ^ F ) 6h &! " G )'J 9J' ' ) " ) b

E2 ) F CM!' 9J #!' + ^ F ) 6h M!' ) 'f #!' ) ' % & ) b

< Y' L + ^ F ) 6h &' G # % H ' )

eh • J ƒ J8 ) F (R ) a ) O 6h Jx

) : 1'

C ! )

3.2.SERVER MANAGER LINE MODE

3.2.1 Truy nh p Server Manager Line Mode

W i )(R ^ F )j > h 9J' ) : 1' ' " x C:\svrmgrl

E" J8 t 9J' ) : 1' #J ( s % $ F h * :( kx ' ) " ! „• )…svrmgrl30 93svrmgrl

T'f x

C:\svgrmrl command=”connect internal/admin” C:\svgrmrl command=@c:\example.sql

rJ' ) : 1' 6c ) R s

.… s Œ }„ 2r r k k r r }r

r* ) : 1' • > h s = : 'f 6'& <:w : E" = 6(n % B %k s O# ! H8 Ž •ˆ

.^ F ) %k s Ž wˆ6h % B = ' ) (R ) n! 6o O# ! +# C 6h M $ ) ~ )

(26)

3.2.2 Phân nhóm l nh Server manager

m lt $ lt

: % ) P % $ *

EXIT REMARK SET SHOW SPOOL

E" P

#Z 58I

!

CONNECT/DISCONNECT DESCRIBE

EXECUTE SHOW ERRORS SHOW PARAMETER SHOW SGA

E" P

#Z 58I

! 6f

CONNECT… AS SYSDBA CONNECT… AS SYSOPER ARCHIVE LOG

RECOVER DATABASE STARTUP/SHUTDOWN

3.2.3 Di$n gi i l nh Server manager

$ lt ™ •

EXIT e> ) : q' % • '" % p )

REMARK 4# 9J' R B € • (R ) ^ F ) ' ) G : !

SET ! 'f 6] " + O > ' ) ! J# R

SHOW T h " 6f R

SPOOL E ' ! |! 'f ' ! |! 8h (* ) % M O G

CONNECT/ DISCONNECT

7 $ 'f U % $ *

DESCRIBE [ # O B b #- G ' • ! % ) • ! % ) ' 8• ! ' • • ' ‡ • Y

EXECUTE s #- ~ ) <:w :

SHOW ERRORS T h " V ! " b b F • J# ! % )

SHOW PARAMETER T h )" R b #- I # $ 6o % &'

SHOW SGA T h ) 9I /0 b R

CONNECT/AS SYSDBA

7 $ * 9* 6f 58I

ARCHIVE LOG 6- ) 9J S ) ( s 6- ) 6$ 9* " G ' ' ') G • ' ') G

RECOVER DATABASE

< F c & #- I !

STARTUP/ SHUTDOWN

(27)

3.3.ORACLE ENTERPRISE MANAGER

C ! ) i 1Cj J ! ( ) ' ! |! > 6(n " ] ) h 9I 'J -$ ) ' ) 6> > =8 ! = O! 9J " 6c y 9I " 6$ (n ) 9J ) B ) ' ) $ )

1C > " ) 0) ! ' ' ! |! k S M " 9F ) v '##' ( ‡' • •‘ #- " A J )

1C „ ) ' )c# ) Z ) F ) k 84 x @Q01 ) # < %• ) # < %

Q4 & 6>• 1C ~ ) O! #- (n ) * " J# 0< ' ! |! + n! 9* " $ ) k Z ) F ) % " Q ' )c# " $ ) k b 9J % ) ! b

C1 E' ' > ' ) q 'Y X 9J q 'Y d;

T3 9ƒ K C ! )

3.3.1 Ki n trúc OME

7 B 1C J # - ) b % B E w • > > % B *!

:*! Z O Z " ’9 v ' ' 9J " Z ) F ) + n! ' ! |! J 6f 9J &8 " q 'Y

:*! Z J ) # v E Z { ) + b J M^ k 9J O " " 9F b $ )• ! ) k 9J ! = ! $ I % h ) "

9J " B I % h v # ) ' C1 ^ F ) C ! ) !' ' 6h $ )• Z ) F ) 9J " & ) " b " s h I % h ! = " ' ) $ )• ' ! |! )(R a ) > h ! 9J ‚ " 9a )

(

:*! Z ' )c# " 6+ ( • ' 9J " 9F k % "

3.3.2 Các d ch v chung

C1 > " 9F ' ! |! k " ' #& ) i Y' %j

@ 9F ! " v @ '9 x C1 s 6- ) ! " i6 j O "

9J " 9F &8 " ' • #- % " ' 6(n M" E" 9F J8 ' )c# q • • # • ! • ' • 9J " % " ’' ) #x ' ! |! s s 6- ) f! & " " 9F T $ ) ' ! |!

(28)

C9 ) # #x ' ! |! k #2 (R ) #& ) i Y' % ' # j M^ k " (R ) n! #O 9F• 'f 9a ) ( • 9J " 9O 6I % " ( ^ F ) J ) 84 E<W 1V % " 6(n ! " • )(R > h ) "' 'f

^ >

Q ' # v 8x " # $ ' # M" ' S ) 9F i j• 6$ (n ) i' ‡ j• 9J S ) i # ' j

@ 9F % ' ( ‚ i l !' ' 8j

C1 J #- $ ) )(R a ) v # # 1V > #- ' ) 6h 6{ ) ! 9J' $ ) a8 ' 6f 58I & • #J > h ! 9J' " ( ' ) % ' ) =#• % ' 6(n ‚ ' O " b C1 6h s

2 ) k

3.3.3 Oracle Configuration Assistant

E' G ) ' J ) F ' ! |! &' " !' ' • 6f & O ' 9J 6f O ' " ' ' ' i6 I % h F -j E' G ) ' 6(n s 6- ) % 6- ) ) % 'J O 5" J 6f b W

„ ) > h % 6- ) Z ) F ) J8 \ ) i &8 %emrepmgr S O _ $ )j

3.3.4 Oracle Enterprise Manager Console

Q ' )c# =8 ! = O! 9J 6c y h A " 6$ (n ) ' ) $ )

o šq y z› œ ' ! |! )y " Z ) F ) % " 6h a ) s " " 9F i %j r J8 „ ) > h s ) #F y ( ) Z ) #

k k q•r rŠfl rœ 6(n ] Z (* & ) =8 ! = O! X> ' ! |! M # " ' ) #& ) J# X ) ' ' ! |! > h 'Y " • ( • • ' • 9J # • 6> > h ^ 6] " + O b " 6$ (n )•9+ Fx )(R a ) > h 6] - ) b ) •q r|œ ' ! |! s " " 9F S M * • ’'

8 # s " b F ' ) '' E' ' : ) ) i E:j )

T3 9ƒ C ! )

r ' ! |! % &' " Z ) F ) % " 9J s I " 9F % "

; kf f kf kl rž ' ! |! " > h 6(n )-! & a8 ' 9I % ) ) • Z { )• ! Y ' ! |! )(R ^ F ) ! ) 9J' " 6$ (n ) P k

? ( r r| I % h 9J ) "' " & ) " b $ )

3.4.CÁC CÔNG C QU N TR KHÁC

(29)

! k r k k rœ a ) 6h I % h ) g 9J % &' " # $ * " + O b

2 r|k k k rœ a ) 6h &' ! 9J k " 6$ (n ) ( • M • 9J Y 2r k k rœ a ) 6h k " 9J ! = 58I ' " J8

2 k r k k rœ a ) 6h ] Z " G 9J k " ' % )#

27 N x rrœ ) ' ! ' % h ~ ) • > ' ! |! s " = : 9J <:w : „ ) ( J " = b )

Bk x f k k rœ a ) 6h ' ( • ! F c 9J ' • k " ' ') G

k k k k rœ a ) 6h &! 9J ] Z & ' )

X)'J " " ) F %h • ~ V n " ) F J# { ) (R ) O J# b @0 0Q0.C

,r• |k r k k rœ h A O J# b (* & ) h 6c 6c '&

$ fY2r k k rœ h ) 9I " ' b K ' > ^ F ) J ) 84 $ )• _! M ! ' Z s ) # P E2 ) F J8 ~ ' ! |! % '

x k k rœ ' " ) % '" i ' %j " 6$ (n ) ' ) E" ) 6(n h A (* & ) 6c '&

(30)

Ch ng T%O DATABASE

4.1.CÁC B& C T%O DATABASE

6o V n #- ) F ' ! |! &' I J q 'Y #- " s e> J ) F @ • ' ) #- $ (R ) n! ) F J8 p % ) 6(n _#

Q4 & ^ F ) ) F ) O! ` b 6h &' • ~ ' ! |! > h &' #J % ) ^ F ) " ) F b < ( ) ! "! J8 )y J &'

\ ) N #

r &' 6(n J ' " (* x

8 y s 9J O E y N ! %k s

^ F ) ' )

! " $ )

E H G # $• &' G # % H i > ' " J8j

E H ! F 9F

; &'

? E &8 ! 6h &' " ' '

4.2.CHU'N B MÔI TR&(NG

4.2.1 Chu)n b h i*u hành

eh &' • (* ! > h ! 9J' I J 9* 6P8 6b 58I (* % &' • P + '" ) (n ) - * ' { Z 9J' O b 9J # ' > 6b - * 6h s " b #- "

+ '" (n ) 6g $ ) P ' ( " G • " ' ' G • " ' ') G 9J " G % "

4.2.2 Lên k ho ch b trí file thơng tin

eh ' 'J ' • P > % '& $ + " G ) Control files

eh # ' 'J • #- P + O K ' ' G 9J 6(n 6f & V % " E" ' ' G 6(n 6f % " ' ' A J ) > h ! =

4 b E' ' G 6(n 6f %•# 9* b ' A *• ( x CTL<n><database_name>.ORA

r* x

n s th t c a control file

database_name tên c a database

' ) ! # G • b " ' ' G 6(n 6f ! = " " O ! H8 r+ Fx

(31)

Online redo log files

' ') G ) (R ) ' )c# I ># " ' ' ') G % " r* #V ># Z " ' b " ' ') G ( ) s ( ' ' G E" ' ' ') G

„ ) 6(n 6f " * % "

E„ ) ) $ ) ( E' ' G • 6f ' " ' ') G 6(n 6f %•# 9*

b ' A *• ( x

LOG<n><database_name>.ORA r* x

n s th t c a control file

database_name tên c a database

4 b " ' ' G 6(n 6f ! = " " O ! H8 r+ Fx

logfile = ‘C:\ORANT\DATABASE\LOG1KTKB.ORA’ SIZE 1024K, ‘C:\ORANT\DATABASE\LOG2KTKB.ORA’ SIZE 1024K

Datafiles

4 b G 6(n 6f ' ( - ) b > e$ 9* " G • P =# * #- $ + O x

/ # h ! = 6'& ' ) " G

" ) " 6$ (n ) ' ) ( " " !! ' • #!' " ! % "

E" G 6(n ! = ' " )# % " b B ) (R ) 6(n 6f 9* J BE ~ ! P 6P ƒ 6(n ! = ' S ) '& )# ( ) Z )

r+ Fx

C:\ORANT\DATABASE\KTKB\SYSTEM01.DBF C:\ORANT\DATABASE\KTKB\RBS01.DBF C:\ORANT\DATABASE\KTKB\RBS02.DBF C:\ORANT\DATABASE\KTKB\USERS01.DBF C:\ORANT\DATABASE\KTKB\TEMP01.DBF C:\ORANT\DATABASE\KTKB\TOOLS01.DBF C:\ORANT\DATABASE\KTKB\INDX01.DBF

4.2.3 Optimal Flexible Architecture – OFA

e I y ) % &' J ] Z " G $ ) ' ' A J ) ' • 4# #* 9J ] ) " 9J' F ) " ' " 9J' b $ ) L09* " + ) B! ' ' 6(n )

E" B b L0x

ef " 6h > > h Z 6s ) " ) $ ) ( #- ! n!

2 < = " G ! H#• ' )c# " ! P #I# 9J " ) F • " G • G ! % &'•

(32)

4.2.4 C u trúc th m c ph+n m*m Oracle

$ z |„ ™ •

Q E Z " G ! H# & ) ! =

@ E Z " G

: E Z " G ( ! H# b

E Z ( ) 9J " G ! F 9F ' J 6f

l # E" G • " G ( 9J " G % " P ' < <:w : 9J " ! H#

.5! :•<

X Y' % E" ! H# X

.9 #) # )

n o z |„

$ z |„ ™ •

0 # L !

@ #' L 9J " ! # '&

@' lC0@1C G

E" G ! F 9F ' J 6f

: E" ( ! H#

:') E" G ')

4.2.5 Bi n môi tr ng

4 I J q 'Y • ! " #2 (R ) E" J8 ( ) Z ) 9* " # $ ' ) ) (xORACLE_HOME•ORACLE_SID•NLS_LANG

eh &' #* • P &' #* #2 (R )ORACLE_SIDx C:\set ORACLE_SID = U16

4.3.CHU'N B CÁC THAM S TRONG PARAMETER FILE

7 &' #* #- • P =# * &' ! # G < # G Z " ) P ' ) • ' ) 6> =# O J " # $ x

$ k| ‘ ™ •

DB_NAME b • $ %k s ! a ) 9*

) " b #2 (R )ORACLE_SID

CONTROL_FILES : %4 " " ' ' G ^ F ) ' ) $ h > K ' ' G ' ) • &' K ' ' G 6h 6I ! ~ ) p ) G E" ' ' G % ) P ! c &

&' • ƒ &' " ' ' G J8

DB_BLOCK_SIZE [" %+ (* b #- ' % ^ F ) ' ) 7+ (*

J8 ƒ % ) 6] 6(n % 6o 6(n &' ! 7+ (* b " ' % 6(n + ' i7 ' j

7+ (* b ' % (R ) 6(n 6f \ ) $ ) 84 P “ S b 6h ( ) Z ) 9* $ ) 84 P " ' % k b I J @' 6>• > h $ ( 6(n $ P M O 6g Z ) r+ Fx 7• 7• 7• ?7•

(33)

2 ) (R )• % H ! # G b #- _! 6(n &'• > h ' |! & - ) b ! # G #€ c t ^ & #- 9J ) $ ' ) 6> ( db_name• control_files•

< # G #€ b ' (R ) 6(n 6f ( #F x <%ORACLE_HOME%>\ADMIN\SAMPLES\PFILE r+ F 9I - ) b G # $x G W ?'

db_name = U16 db_files = 1020

control_files = ("C:\ORANT\database\ctl1U16.ora", "C:\ORANT\database\ctl2U16.ora")

db_file_multiblock_read_count = 16 db_block_buffers = 2000

shared_pool_size = 30000000 log_checkpoint_interval = 8000 processes = 100

dml_locks = 200 log_buffer = 65536

sequence_cache_entries = 30 sequence_cache_hash_buckets = 23 #audit_trail = true

#timed_statistics = true

background_dump_dest = C:\ORANT\rdbms80\trace user_dump_dest = C:\ORANT\rdbms80\trace

db_block_size =8192 compatible = 8.0.4.0.0 sort_area_size = 65536 log_checkpoint_timeout =

remote_login_passwordfile = shared max_dump_file_size = 10240

4.4.CHU'N B INSTANCE PH C V QU N TR

.^ F ) ) F ORADIM 6h &' ! F 9F ' &' ORADIM ƒ &'

#-9 J ) ' e=8 J #- ) F s 6- ~ ) E2 ) F J8

t P % &' #* • ^ 6] U b \ ) ' ) (R ) n!

^ F ) ) F @ E' G ) ' 6h ! 9J' % ) P

! * ) F J8

&%' ! & k lr k kqk r • k

' k

E> h &' #* • • '!• ^ 6] M'" p

7 ) ! * G

E t > h &' #* U p ) h '!

E> h ^ F ) 6h ^ 6] ) h 6h ^ 6] @a ) 6h &' ! Y' G 9J

7 ) &' 6(n

@a ) 6h &' ! Y' G 9J

5 • 9J

z ‡œ ‰ " ! (* b • ) FORADIM > JORADIM80

(34)

EB ! "!x

C:\>ORADIM -NEW -SID SID | -SRVC SERVICE_NAME [-INTPWD INTERNAL_PWD] - SHUTTYPE SRVC | INST | SRVC, INST [-MAXUSERS NUMBER][-STARTMODE AUTO | MANUAL][-PFILE FILENAME]

V i:

-NEW T o m i instance ph c v cho database

-SID SID Tên c a instance c t o (tên th ng c l y tên c a database)

-SRVC SERVICE_NAME

Tên c a service ph c v database -INTPWD INTERNAL_PWD

M t kh u c a Internal account s d ng qu n tr database

-MAXUSERS NUMBER

S l ng user t i a nh ngh a password file -STARTMODE AUTO, MANUAL

t ch kh i ng instance ph c v (kh i ng service máy ch server)

-PFILE FILENAME

Ch rõ parameter file INIT<Database_name>.ORA -SHUTTYPE SRVC, INST

D ng instance ph c v (stop service) r+ Fx

C:\> ORADIM NEW SID PROD INTPWD MYPASSWORD1 STARTMODE AUTO -PFILE C:\ORACLE\ADMIN\PROD\-PFILE\INIT.ORA

4.4.2 Kh i ng instance

EB ! "!x

C:\ORADIM -STARTUP -SID SID [-USRPWD USER_PWD] [-STARTTYPE SRVC | INST | SRVC, INST] [-PFILE FILENAME]

V i:

-STARTUP Kh i ng instance ph c v s n sàng cho vi c t o database

-SID SID Tên c a instance c t o (tên th ng c l y tên c a database)

-USERPWD USER_PWD

M t kh u -STARTTYPE SRVC, INST

Ch kh i ng service hay instance r+ Fx

C:\> ORADIM -STARTUP -SID PUMA -STARTTYPE SRVC -PFILE C:\ORACLE\ADMIN\PROD\-PFILE\INIT.ORA

4.4.3 D,ng instance

EB ! "!x

C:\>ORADIM -SHUTDOWN -SID SID [-USRPWD USER_PWD] [-SHUTTYPE SRVC | INST | SRVC, INST] [-SHUTMODE A | I | N]

(35)

-SHUTDOWN D ng (stop) instance ph c v

-SID SID Tên c a instance c t o (tên th ng c l y tên c a database)

-USERPWD USER_PWD

M t kh u

-SHUTMODE Xác nh ch d ng: A – abort mode, I I – Immediate mode, N – Normal mode

r+ Fx

C:\> ORADIM -SHUTDOWN -SID PUMA -SHUTTYPE SRVC INST

4.4.4 Hu- instance

EB ! "!x

C:\>ORADIM -DELETE -SID sid r+ Fx

C:\> ORADIM -DELETE -SID PUMA

4.5.T%O DATABASE

4.5.1 Kh i ng Instance

.^ F ) 9* #Z 58I @Q0 @a ) ) FORADIM6h &'

7 6- ) 6-NOMOUNT 9J t … G # $ ^ F ) ' ) ( ) x

SVRMGR> STARTUP NOMOUNT \ > PFILE=initU16.ora

4.5.2 L nh t o database

.^ F ) = CREATE DATABASE6h &' EB ! "!x

CREATE DATABASE [database] [CONTROLFILE REUSE]

[LOGFILE [GROUP integer] filespec [, [GROUP integer] filespec] ] [MAXLOGFILES integer]

[MAXLOGMEMBERS integer] [MAXLOGHISTORY integer] [MAXDATAFILES integer] [MAXINSTANCES integer] [ARCHIVELOG|NOARCHIVELOG] [CHARACTER SET charset]

[NATIONAL CHARACTER SET charset]

[DATAFILE filespec [autoextend_clause] [, filespec [autoextend_clause] ]]

filespec :== 'filename' [SIZE integer][K|M] [REUSE] autoextend_clause :==

[AUTOEXTEND {OFF

(36)

[MAXSIZE {UNLIMITED|integer[K|M]}] }

] r* x

Database Tên c a CSDL c n t o (tên gi ng v i tên c a tham s DB_NAME parameter file)

CONTROLFILE REUSE

Tên file tham s ã t n t i c tái s d ng LOGFILE GROUP

Tên c a log file c s d ng MAXLOGFILES

S l ng t i a log file group cho CSDL MAXLOGMEMBERS

S l ng t i a log file member i v i m t log file group

MAXLOGHISTORY

S l ng t i a redo log m t group DATAFILE filespec

Tên file d li u c s d ng AUTOEXTEND

Cho phép ho c không cho phép m r ng t ng file d li u

MAXDATAFILES

S l ng t i a datafiles database MAXINSTANCES

S l ng l n nh t instance có th ng th i mount open database

ARCHIVELOG

Xác nh ràng redo log c n ch archive tr c c dùng l i

NOARCHIVELOG

Xác nh ràng redo log c n c dùng l i mà không c n t ch archive

CHARACTER SET, NATIONAL CHARACTER SET

Chu n ký t mà CSDL s d ng l u tr d li u r+ Fx &'

SPOOL creU16.log

STARTUP NOMOUNT PFILE=initU16.ora CREATE DATABASE U16

MAXLOGFILES MAXLOGMEMBERS MAXDATAFILES 100 MAXLOGHISTORY 100 LOGFILE

(37)

DATAFILE

'/DISK1/system01.dbf' size 50M autoextend on CHARACTER SET WE8ISO8859P1;

4.5.3 Oracle Database Assistant

eh &' • V n ) F O n ) B! )(R A J ) &' ) ) ' 6c '&• 6> J ) F @

T3 9ƒ E2 ) F &' V n N @

r* ) F J8• )(R t % "' " # $ P '

@ ƒ s 6- ) % = : ( ) Z ) 9* " # $ 6o 6(n % "' E" = : > h 6(n &8 'f „ ) > h 6(n ( & J " ! G ^ F ) J8

4.5.4 File script ví d t o m t database

L ?

set ORACLE_SID=U16

C:\ORANT\bin\oradim -new -sid U16 -intpwd oracle -startmode auto -pfile C:\ORANT\database\initU16.ora

C:\ORANT\bin\oradim -startup -sid U16 -starttype srvc,inst -usrpwd oracle -pfile C:\ORANT\database\initU16.ora

C:\ORANT\bin\svrmgr @U16run.sql L W ?

spool C:\ORANT\database\spoolmain set echo on

connect INTERNAL/oracle

startup nomount pfile=C:\ORANT\database\initU16.ora CREATE DATABASE U16

LOGFILE 'C:\ORANT\database\logU161.ora' SIZE 1024K, 'C:\ORANT\database\logU162.ora' SIZE 1024K

MAXLOGFILES MAXLOGMEMBERS MAXLOGHISTORY

DATAFILE 'C:\ORANT\database\Sys1U16.ora' SIZE 50M MAXDATAFILES 100

(38)

CHARACTER SET WE8ISO8859P1

NATIONAL CHARACTER SET WE8ISO8859P1; spool off

L W ?'

db_name = U16 db_files = 1020

control_files = ("C:\ORANT\database\ctl1U16.ora", "C:\ORANT\database\ctl2U16.ora")

db_file_multiblock_read_count = 16 db_block_buffers = 2000

shared_pool_size = 30000000 log_checkpoint_interval = 8000 processes = 100

dml_locks = 200 log_buffer = 65536

sequence_cache_entries = 30 sequence_cache_hash_buckets = 23 #audit_trail = true

#timed_statistics = true

background_dump_dest = C:\ORANT\rdbms80\trace user_dump_dest = C:\ORANT\rdbms80\trace

db_block_size =8192 compatible = 8.0.4.0.0 sort_area_size = 65536 log_checkpoint_timeout =

remote_login_passwordfile = shared max_dump_file_size = 10240

4.5.5 L.i x y t o database

:V M % &' ! P * ' " ) 84 = x :V B ! "! &'

E" G P &' ! 6o c &

:V ' I J • % ) > 6b 58I • % ) 6b V $ )•

4.5.6 K t qu sau t o database

7 B " (* 6(n #- 9* x K G 6(n 6f ' ) u C1 ! E" ' ' G 9J " ' ') G ! F 9F '

T 9J # % H ( ) Z ) Jx SYS/change_on_install 9J SYSTEM/manager

K l' % )# u C1

E" ) 9* $ )

4.6.T%O DATA DICTIONARY CHO DATABASE

(39)

% ) h J' " " ) ' ) > 6(n eh > h " 6(n " ) ' )

P &' ' ' J8

@ ' 8 ~ )y J S h b J ! n! " Y 6(n ! ' ) ) O! " ) 9I

E" G &' ' ' 6(n ) O! ` 9J (R ) 6(n 6f ' ) ( #F <%ORACLE_HOME%>\RDBMS\ADMIN

E" ' Y 6(n ! = '& 9J 6f ' ) " G : % " 1- $ G : a )x

$ •lr27 ™ •

CATALOG.SQL &' " ' Y • )) 9J ' ! ' CATPROC.SQL &' " ! % )

(40)

Ch ng QU N TR ORACLE DATABASE

5.1.PHÂN LO%I USERS

J #- * • &8 #2 (R ) #& ) eh J $ ) 6(n $ • > h > I )(R ƒ a ) # ) 9J' $ ) 9* ) ~ % " )y J

" E> h ! = J# #- $ '& + x

@ # '

GG

0!! ' @ '! 0!! ' # '

@ W

X Y' % # '

5.1.1 Database Administrators

@' $ ) > h J O * 9J > I a ) # ) 9J' $ )• 9J % 6> ƒ > #- #- $ )(R " # k $ ) X ) )(R > ~ (

6(n )y J # ' i@Q0j 1V #- P + O K )(R 6h s

2 )

1- # ' > " # s #- $ ) x

EJ 6f 9J = ) O! 9J " ) F Z ) F ) % "

< = ! $ $ ) ( 9J % '& ( ' $ ) ' ) ( ) &' ) O B ( ( ! ! F 9F ' ! " h 9J '& 6- ) b " Z ) F )

&' " 6$ (n ) ' ) ( • Y • M ^ F ) ' " Z ) F )

6(n %

8 6] O B % P † ' " ) b " !! ' k " 9J # ' ' # $ )

e # ' ( ) + 9I 58I • ! 9* $ ) e I % h 9J " M O *

W k 9J $ ( " M O *

:4 % '& % ! i ' ( j 9J '9 i! F c j " ) > ' ) :( "

' ( 9J % ! F

E ! " ) ) #* 6( " = p ] +

5.1.2 Security Officers

' ) #- $ (R ) n!• $ ) 6~ p 6- ' # ' 6> P #- #- ># )(R 84 s ) " ' )y J 'GG 'GG > h % $ * • I % h 9J k ! b " 9J ' # $ )

5.1.3 Application Developers

0!! ' '! J )(R % 9J " Z ) F ) 0!! ' '! > " # s #- $ 84 P x

% 9J ! " h Z ) F )

% O B ' S ) Z ) F ) e" ) " 84 P ( ' Z ) F )

(41)

! ! "! ' # ' Z ) F ) 6(n ! " h

5.1.4 Database Users

@ ( ) " 9* ) " Z ) F ) 9J " + 1- h > h s 6(n #- $ ) x

8 !• ^ 6] • 9J M'" U " 6(n ! |! &' " "' "' 6$ 9*

5.1.5 Network Administrators

e$ 9* '& 62 ) #2 (R ) #& )• % 6> P > #- s ) #& ) W J8 > " # # ' " Z ) F ) '& 6- ) #2

(R ) #& ) 6(n $

5.2.PH& NG TH/C XÁC NH0N 1C QUY2N TRUY NH0P

r ! = 58I ^ F ) J P ' ) ) E> ' 6(n s 6- ) &' ) S % &' 9J 6(n )" 58I @Q0 Jx u 9J u C1

2G2œ 6(n &' s 6- ) 9J )" 8I @Q0 % H #f J ) m' m E> 58I " ) 9J " S h ' )

2G2$( œ 6(n s 6- ) &' 9* # % H 6P J # ) 9J „ ) 6(n )" 58I @Q0 • u C1 ~ 6(n #- $ • Y # - ) Z " )

^ F ) ' " '' b

8I B'x X) % &' • 6o &' ` #- 58I )y J ”@Q0” 8I J8 ' ! |! s " ' " 6$ 9*

z ‡œ r* 58I @Q0• " J8 ƒ > h ! 6(n * " 58I b " % " ^ F ) ' ) $ ) r3 • ) P 6] # % H b #3 " ^ F ) # % H #f ' ) O! 93 % " > h 9J ^ F ) 6h ! 9J' $ ) #- " " ! |!• )=8 M"' - $ )

5.2.1 Ph ng th3c xác nh n quy*n

' ) #- $ (R ) n! P ! ( ) Z M" 58I ! 6f ' > h B 6> ( 6(n # • 9+ F ( 9* " (R ) n! 'Y 'f

!

† - 9J' a ) #- #"8 #"8 % " #J > h ^ F ) M" 58I ! I J 8 ! Y' G

(42)

5.2.2 Xác nh n quy*n b i h i*u hành

r M" 58I I J 6(n J ' " (* x

1 ' ) I J q 'Y X &' #- ˆ) ' ! 9* ORA_<SID>_DBA 9J #-># % " ORA_<SID>_OPER9* <SID> ( ) Z ) 9* b • 'f ORA_DBA 9JORA_OPERi% J8 % ) =# * j

2 4# #- 9J' ) ' ! 6h % ! 9J' I J • > h s 6- ) 6(n M" 58I @Q0

3 ef # $REMOTE_LOGIN_PASSWORDFILE ' ) ! # G JNONE $ * 9* #Z 58I SYSDBA 8SYSOPERx

CONNECT / AS { SYSDBA|SYSOPER } / Bx

XC 6(n J 6f " I J q 'Y d;• q 'Y X 6h ) B! ' M" 58I

E" ! (* b ^ F ) x CONNECT INTERNAL 9* B ! "!xCONNECT INTERNAL/pw AS SYSDBA : x CONNECT INTERNAL & 9€ 6(n ^ F )

r* M" 58I ! I J • % ) P =# * " #Z 58I i! ) j 9J' 6>• P =# * 58I 6(n ) O! I

J JOSDBA9JOSOPER

&2&,(%x J 58I ' ! |! > h STARTUP• SHUTDOWN• ALTER DATABASE OPEN/MOUNT• ALTER DATABASE BACKUP• ARCHIVE LOG• 9J RECOVER• )'J ~ > 4# 58I RESTRICTED SESSION

&2 B'x J 58I ' ! |! > h > 6(n O " 58I b OSOPER• )'J ~ > 4# #- $ #Z 58I ! F 9F JADMIN OPTION• 9JCREATE DATABASE

5.2.3 Xác nh n quy*n b4ng file m t kh)u

V n " + ! Y' ' ! |! % $ * ^ F ) # 9J ! Y' r ! 9J' ^ F ) ! Y' G 6(n V n GRANT

2Œ }„ •lr|‰ x Ÿ œ

1 &' G # % H \ ) x

orapwd file=<fname> password=<password> entries=<entries> V i:

fname tên file m t kh u

password m t kh u c a SYS hay INTERNAL

entries s l ng t i a qu n tr viên c phép ef # $REMOTE_LOGIN_PASSWORDFILE JEXCLUSIVE 'f SHARED

V i:

EXCLUSIVE ch m t instance có th s d ng file m t kh u SHARED nhi!u instance có th dùng file m t kh u /" 58I '

GRANT SYSDBA TO admin; GRANT SYSOPER TO admin $ * ' B ! "!x

(43)

Jr| ƒ w |r|qr •lr|‰ x Ÿ

2 ) 9I " # # ' ) G # % H 6(n ( ' ) Yx V$PWFILE_USER X> ' > ) J' 6(n )" 58I SYSDBA 8SYSOPER

@ A ) #- $ - ' )V$PWFILE_USERx

USERNAME Tên user

SYSDBA C t nh n giá tr TRUE User c gán quy!n SYSDBA

SYSOPER C t nh n giá tr TRUE User c gán quy!n SYSOPER

7 % $ 9* ' #Z 58I SYSDBA SYSOPER• 6> ƒ 6(n % $ * " # #f • 9* SYSDBA # #f J SYS• 9* SYSOPER # #f J PUBLIC

5.2.4 Thay 5i m t kh)u internal

.^ F ) + l0@ 6h &' & G # % H

C:\>ORADIM -NEW -SID sid [-INTPWD internal_pwd][SRVC

svrcname][MAXUSERS n][STARTMODE auto, manual][-PFILE filename]

r* x

sid tên instance

internal_pwd m t kh u internal account svrcname tên service

n s l ng t i a file m t kh u

auto or manual ch kh i ng service là: manual hay automatic filename cho phép s d ng file m t kh u không ph i m c

nh

eh 6] # % H INTERNAL s ' " (* x ['" # % H „

C:\> ORADIM -DELETE -SID sid &' # % H #*

C:\> ORADIM -NEW -SID sid -INTPWD internal_pwd - MAXUSERS N

5.3.T%O PARAMETER FILE

(44)

L # $ ) (R ) > init<SID>.ora

' #f • G # $ 6(n 6f ' ) ( #F %ORACLE_HOME%\DATABASE

L # $ t 6(n 6y #- P % % 6- ) 6] - ) b G # $• 6h ^ F ) 6(n " ) " #* P 'Y c 6> &

5.3.1 S6 d ng tham s

E" # $ > h ( ) * ^ F ) E" ) $ ' ) G # $ ' )c#x

7+ (* b 9a ) # / ' i./0j 6h $ ( O

ef #f ' 9J

ef " & 6$ 9* ! ' ef " & 6$ 9* J ) 84

[" " - + k b • ( %+ (* b ' % E t " ' ' G • ') G • G • 9J G ' '

5.3.2 M t s quy t c i v i tham s

E" ) " 6(n t ' % & )x<Keyword> = <Giá tr >

1- $ # $ 6I J † y 9J #- $ % " J _ - 9+ F ( DB_NAME

6I > ) " #f 6$ 9* #V # $ E" ) " J8 J † ' I J 9J † ' # $

E" # $ > h 6(n t % ) P ! = ' #- Z s J' i6f (* • % ) y )j

< P B € 6(n _ 6P \ ) %k • E" # $ J %k s 6(n 6f ' ) O "8 %|! E„ ) > h " G S % '" L :C

E" ) " J ! n! 6(n 6f ' ) O )'f Ži•jˆ9J 6(n ){ " O ! H8 i•j

5.3.3 Các tham s c b n

$ k| ‘ ™ •

CONTROL_FILES b " ' ' G

DB_BLOCK_BUFFERS $ (n ) " ' % 6(n ' ) /0

DB_BLOCK_SIZE 7+ (* b #- ' % 7+ (* J8 6(n y

\ ) $ $ ) 84 P #„ • > h J 7• 7• 7• ?7 9J † ' ! b 9J b T I J

DB_NAME e S %k s M $ ) # $ J8 t P

% &' #*

#-IFILE b G # $ 6(n 9J' G # $ R E '

! |! > h 6(n c ) $ J O!

LOG_BUFFER $ 6(n O! ! " ' ' ') GG ' ) /0

MAX_DUMP_FILE_SIZE 7+ (* $ b G • 6(n M" \ ) $ (n ) ' % b I J

OPEN_CURSOR $ (n ) ' $ 6(n 6c ) R #

ROLLBACK_SEGMENTS $ (n ) ' % )# 6(n ^ F ) ' #V

PROCESSES $ (n ) $ " I J > h % $ 9*

(45)

r+ F #- ! # G x

T3 9ƒ ; L # $ 9+ F

5.4.START VÀ SHUT DOWN DATABASE

5.4.1 Các b c Start Shut down database

2 k ! k r • h€ |

> h % 6- ) #- #J % ) P ! )_ 9* #- F h % 6- ) • " ) 6=8 ƒ 6(n s x

ey G # $ xinit<SID>.ora M ! 9a ) - * /0

7 6- ) " %) ' ! ' " G 9J " G

:( kx \# ' ) # $DB_NAME b G # $ E= x

STARTUP NOMOUNT; k ! k r • h€ |

eh s #- 9J ' " 6f % J • > h % 6- ) #- 9J

#' ( ) ( #

r+ F (x

e] G

C 'f @ " ' ') G

s ! F c i '9 8j

E" ) % #' x

/_ 9* #- 6o % 6- )

e 9J # " ' ' G ' ( ) $ > ' ) G # $

ey - ) b ' ' G 9J M" & ) " ' " G 9J " ' ') G E= x

(46)

% 6o 6(n # • ) )(R ^ F ) n! > h % $ * 9J s " ' " ! 9J'

r # A ' (* x

1 " ' G " ' ' ') G E= x

STARTUP OPEN;

T3 9ƒ ? E" (* % 6- ) 9J S )

ƒ f „ ! k r

' ) #- $ (R ) n! > h )f! V 9J % ) h J# 6(n r+ F (x > V $ ) M r % ! F ƒ 6(n s ' " (* x

7 ! F & O " > h % ! F 6(n i ( 6(n ( 9J' G ( ) 6o ( 9J' ' ) ' ' ') G j

1

7 ! F & O " ' ( 6(n '## l r}k kqk r

e=8 J (* 6P % _ Œ #- % 6> ) • O " ~ ' ) - # i ' ') GG j ƒ 6(n ) G i' ' ') G j E" ' ' G 9€ 6(n #

| }k kqk r

@ #' ƒ 6> ) $ " ' ' G - ) #

2 } ž ! k r

e=8 J (* $ a )• ƒ 6(n _ Œ E" G 9J G b 6> ) E" %) ' ! ' S ) 9J 9a ) * /0 O! ' c

5.4.2 Start database

EB ! "!x

STARTUP [FORCE] [RESTRICT] [PFILE=filename] [EXCLUSIVE | PARALLEL | SHARED]

[OPEN [RECOVER][database]|MOUNT |NOMOUNT] r* x

OPEN cho phép users truy c p vào database MOUNT mounts database s n sàng cho thao tác DBA,

(47)

NOMOUNT B trí SGA kh i ng background process, ch a s n sàng cho DBA

EXCLUSIVE ch cho phép instance hi n th i truy c p vào database

PARALLEL cho phép nhi!u instances c g"n v i database (s d ng Oracle Parallel Server)

SHARED t #ng t nh PARALLEL

PFILE=parfile cho phép s d ng file tham s không ph i m c nh xác nh c u hình cho instance

FORCE hu$ b% instance ang ch y tr c ó, kh i ng instance bình th ng

RESTRICT ch cho phép users truy c p v i ch RESTRICTED

SESSION quy!n truy nh p vào database

RECOVER b"t u khôi ph c d li u database

5.4.3 Thay 5i tính s7n dùng c8a database hi n th i

7 6- ) 6-NOMOUNT

s ^ 6] ' x

ALTER database { MOUNT | OPEN | OPEN

READ ONLY | OPEN READ WRITTE} r* x

MOUNT G"n database v i instance Lúc ta ch có th th c hi n thao tác qu n tr database mà ch a th s d ng database c

OPEN READ WRITE M database, s n sàng cho vi c s d ng database, c &c l'n ghi

OPEN READ ONLY M database nh ng ch cho &c database nh s d ng câu l nh truy v n ch(ng h n Các thao tác ghi không th th c hi n c Tu) ch&n c s d ng ta c n chép redo log files c a

database

OPEN T #ng t nh OPEN READ ONLY, ây bi u di*n m c nh c a OPEN READ WRITE

5.4.4 Shut down database

E> #- $ 6- _ ( ) Z ) 9* " % { ) % "

(48)

EB ! "!x

SHUTDOWN [NORMAL | TRANSACTIONAL | IMMEDIATE | ABORT ] r* x

NORMAL Không cho t o thêm connection t i database, ch cho connection hi n th i k t thúc shutdown database

TRANSACTION Khơng cho phát sinh thêm transaction, ch cho transaction hi n th i k t thúc shutdown

database

IMMEDIATE K t thúc transaction hi n th i nh ng v'n ch h th ng commit hay rollback r i m i shutdown database

ABORT Shutdown database t c th i khơng ịi h%i b t c i!u ki n

( ) Z ) 9* " " _ • > h 6c 9I R ) ( x

T3 9ƒ ' " R ) ) " " _

T3 9ƒ ' " $ 9I R ) % s #- ' " 8h 6] x s 9O 6h O8

2 s INSERT9JDELETE6h ! 9J 8h 6] < " COMMIT6h ! 9J'

4 T U p % *

5.4.5 Thay 5i tr ng thái c8a database

EB ! "!x

ALTER system { SUSPEND | RESUME }

SUSPEND a database vào tr ng thái treo T m th i không cho phép th c hi n thao tác vào i v i datafiles control files Thao tác c th c hi n ta chu n b backup database

RESUME Ng c l i v i SUSPEND, thao tác s+ a database tr l i tr ng thái bình th ng sau ã backup xong database

r+ Fx

SQL> ALTER SYSTEM SUSPEND; System altered

(49)

DATABASE_STATUS -

SUSPENDED

SQL> ALTER SYSTEM RESUME; System altered

SQL> SELECT database_status FROM v$instance; DATABASE_STATUS

- ACTIVE

5.4.6 T m treo ph c h9i Database

d ) O! Z { ) ! w # ^ F ) ALTER SYSTEM SUSPEND6h &# ' • S ) #y ' " M O 9J' 6$ 9* " G 9J ' ' G & ) " &# '• " ' " 9J' iI/O operationsj ) s

ƒ 6(n % B 9J ) ! 9J' #* ! " ƒ 6(n 6H8 9J' s ALTER SYSTEM RESUME6h % ! F & & ) (R ) b

^ F ) ALTER SYSTEM SUSPEND6h &# ' #- • ){ s " ' " 9J' iI/Oj 6$ 9* " G 9J ' ' G @' 6>• ' ! |! > h A J ) s " ' " % ! s ' O " ' " 9J' ) > ƒ 6(n ! F ' ! |! s ' % 'J O • " ! |! ' " 9J' #* ! "

J8 ƒ 6(n &# R 6( 9J' R M^ k

: ! i &# 'j 6(n s 6$ 9* Z % ) ! t 6$ 9* @' 8• ' ) #2 (R ) l 0!! ' E • #- % ! 6(n ! " 6> #- % '" ƒ 6(n ! 9J f O " 84 P )^ *

.^ F ) ALTER SYSTEM RESUME 6h ! F c i # j & " '& 6- ) ) (R ) b „ ) > h t …SUSPEND 9J RESUME S " % " r+ F• " • • 9J ) &8• 9J ! " ALTER SYSTEM SUSPEND S instance 1• 6> „ ) > h ! " RESUME Scác instances 1, 2• 83 6I (

7 { )suspend/resume J O + ' $ ) > ' ! |! s # ' #- ] 6g #- G c 6> ^ F ) 9J' ' ( • ! F c ' 'J - $ )

8 8• 6f h# suspend/resume % ) ' " ' " normal shutdown database93 % 6> ' |! database6(n suspend > h Z " !

( 6(n commit

E # '& ^ F ) ALTER SYSTEM SUSPEND/RESUME ^ F ) ) ) O! ' )V$INSTANCE6h 6(n & ) " b database

SQL> ALTER SYSTEM SUSPEND; System altered

SQL> SELECT DATABASE_STATUS FROM V$INSTANCE; DATABASE_STATUS

- SUSPENDED

SQL> ALTER SYSTEM RESUME; System altered

SQL> SELECT DATABASE_STATUS FROM V$INSTANCE; DATABASE_STATUS

(50)

5.4.7 :t ch ho t ng t;nh cho database

d ' ! |! 6( 9J' 6- '& 6- ) g iquiesced statej• ' 6> t "' " DBA transactions, queries• 9J " PL/SQL J 6(n ! |! s & ) " J8 ' ! |! )(R a ) s " ' " #- " 'J s F ) = ALTER SYSTEM QUIESCE RESTRICTED 6h 6( 9I 6- '& 6- ) g

5.5 1T TR%NG THÁI T<NH CHO DATABASE

E> I % P ! 6( 9J' & ) " #J t > " DBA transactions• queries i 9O j• fetches i 3# % # j• " = PL/SQL J 6(n ! |! s

E 6- J8 6(n )y J v &# J 6- g E 6- J8 ' ! |! > h s #- $ ' " % ) 'J _# ' )c# " ' " 6=8x

E" ' " > h )f! V 6c ) R > #- ' ! 9J' a ) #-6$ (n ) r+ F ( % 6] • 4# #* - 9J' #- ) > 9J % ) 84 P % '" ino-wait lock is requiredj

E" ' " % ) #' ) # $ )=8 ( ) Z ) " user transactions M 6c ) R r+ F % > #- b F Z I (* ' " #- Œ ) & ( 6P 6(n M!' • c M'" 9J $ a ) & 6(n #!'

& Ea ) B 6> > % " # $ ! 9J' 9J ) & R h# 9S U J8 ƒ ! " V $ )

X % ) "! F ) & ) " g ' • P ! 'Y c '! & > 6- rJ J8 ƒ ) 4# y ) % $ ) 84 P ! &8 F M D –! F ) 6- g ' ƒ ) # * " & 93 ' 93 > '& * 6(n " MO M 9*

5.5.1 a Database vào tr ng thái t;nh

eh 6( 9J' & ) " g • ) t P ^ F ) x

ALTER SYSTEM QUIESCE RESTRICTED

O " non-DBA active sessions ƒ 6(n ! F M^ k ' * % B ) 8h ) & ) " inactive 1- ' 6(n M # J B 6> > ) > " ! |! s ( ' • 8• G • ) M^ k #- = PL/SQL• 'f „ ) > h J ' 6> ) _# ) ! P J ) 84 ‚ ishared resources)

7 O " ' v@Q0 ' 8h ) & ) " • = ALTER SYSTEM QUIESCE RESTRICTED % B 9J 6(n M # ( J 8h ) & ) " g ' ) #2 (R ) Oracle Real Application Clusters• = J8 >

( ) * O " • Z % ) t J 6$ 9* ! " =

: ALTER SYSTEM QUIESCE RESTRICTED > h ! R ' ) #- R ) % " J 6h ' ' 8h ) & ) " X U p 84 P • 'f ' % B #- " 6- )- 93 I k ' % " ƒ s 6- ) ! F c & i 'j & ) " (* % s

X #- 9O 6(n 6( " E G i E j• = ALTER SYSTEM QUIESCE RESTRICTED ƒ % ) R G O " #J t R G M' ) ~ )

R #J

7 & ) " • % ) ^ F ) I J 6h ' |! " G ' ) $ ) ) $ ) ( % s % ! & 6$ 9* • ' a > " %!' & #V

(51)

5.5.2 Ph c h9i h th ng tr l i ho t ng nh bình th ng

s = x

ALTER SYSTEM UNQUIESCE

7 J8 O " ' v@Q0 ƒ 6(n ! F s ' ) #2 (R ) l 0!! ' E • > h ! " J8 S O %† #- J' > % $ * % )

O ! J ! " 6f & ) " g ' ) (R ) n! ' ! " ALTER

SYSTEM UNQUIESCE )f! V • ƒ # ' s ƒ

% B

5.5.3 Xem tr ng thái c8a database

> h M # & ) " b " ) > ' ) V$INSTANCE E" ) J8 6(n ( ' ) - ACTIVE_STATE 9* " - ) ( x

' $!3(—2$'$( ™ •

X l10: & ) " ) (R )

W C.E X/ e ) & ) " g N • ( ) " ' v @Q0 ' 9€ 6(n s

W C.EC@ ‰ & ) " • 9J % ) > O %† #- ' v @Q0 ' J' 6(n ! |! s

5.6.L=Y CÁC THÔNG TIN V2 H# TH NG

E" ) $ $ ) 6(n 6f ' ) " $ ) > h " 9J M O * B ) ) " Y )y J @8 # ! G' # Y E" Y J8 (R ) > 6P JV_$ (R ) &' " ' 8# ( ) Z ) 9* " Y J8 9* > 6P JV$ % 6- ) 6-NOMOUNT• > h 6y 6(n " > ' ) " Y J8 ) ' ) Y J8 J P ' #'

r YV$FIXED_TABLE Z b O " YV$ > ' ) $ ) Q h 6c (* 6=8 A " #Z 6- ! " Y b $ )

T3 9ƒ d E" #Z 6- ! Y $ )

5.6.1 M t s views c+n quan tâm

k| ,r• |k r3 rž ™ •

V$PARAMETER ) 9I " # $ % &'

V$SGA ) ] ) n! 9I /0

(52)

k| ,r• |k r3 rž ™ •

V$PROCESS ) 9I " '& 6- ) b ! ' R

V$SESSION ) 9I '

V$VERSION ) 9I ! b " J ! P

V$INSTANCE ) 9I & ) " b R

V$THREAD ) 9I " ' ) $ )

V$CONTROLFILE : %4 b " ' ' G

V$DATABASE ) 9I

V$DATAFILE ) 9I " G 6(n ^ F )

V$DATAFILE_HEADER ) b " G 6(n ^ F )

V$LOGFILE ) 9I " ' ' ') G

5.6.2 Hi>n th giá tr c8a thông s h th ng

> h M # ) $ ) \ ) " x ^ F ) M # # $ b # )

SVRMGRL> SHOW PARAMETER control M O s ! 9J' Y $ )

SELECT name, type from v$control WHERE name like ‘%control%’; r* " 6I 6(n #- % x

SVRMGR> SHOW PARAMETER control

NAME TYPE

VALUE

- - - control_file_record_keep_time integer

control_files string /DISK1/control01.con

5.6.3 Tham s h th ng ng (có th> thay 5i)

' ) " # $ $ )• > #- 9J # $ J 6- ) 9J > h 6] 6(n " # $ J8 ) " x

ALTER SESSIONx t 6] ) " b " # $ ' ) ' R ALTER SYSTEMx 6] ) " ' ) 'J - $ ) > )

ALTER SYSTEM DEFERREDx t 6] # $ $ ) b " ' ƒ % $ 9J' J8• %h S R h# 6]

EB ! "!x

ALTER SESSION SET parameter_name = value

ALTER SYSTEM SET parameter_name = value [DEFERRED] r+ Fx

ALTER SESSION SET SQL_TRACE=true;

ALTER SYSTEM SET TIMED_STATISTICS=true;

ALTER SYSTEM SET SORT_AREA_SIZE=131072 DEFERRED; [ # & ) #J 9S 6] x

SVRMGR> SELECT isses_modifiable,issys_modifiable, 3> ismodified, name

(53)

4> WHERE ismodified != 'FALSE'; ISSES ISSYS_MOD ISMODIFI NAME

- - - - TRUE IMMEDIATE MODIFIED timed_statistics

1 row selected

5.6.4 Qu n lý session

Restrict session

l ' P % ' • #!' • M!' 9J ^ 6] O B b

> h 6f 6- ' ' ' ) x

ALTER SYSTEM {ENABLE|DISABLE}RESTRICTED SESSION

r* x ENABLE RESTRICTED ch cho phép users có quy!n RESTRICTED SESSION truy nh p

DISABLE RESTRICTED SESSION cho phép t t c users truy nh p vào database

K t thúc session

> h % B i # j " ' b #- 6o ' ) 6- • (* % s " ' "

EB ! "!x

ALTER SYSTEM KILL SESSION ’integer1,integer2’ r* x

KILL SESSION tên session c n k t thúc

integer1 giá tr c a c t SID view v$session integer2 giá tr c a c t SERIAL# view v$session E B kx ) " ) 9J ) a ) 6h M" '

r* KILL SESSION %) ' ! ' PMON ƒ s " ) x

l' % ' R b

/ ! > ) O " ' % " s 6> / ! > ) " J ) 84 ^ F )

5.6.5 Trace file ALERT file

G ( " ' " %) ' ! ' E" ) 9I V ' ) $ ) ƒ 6(n ( 9J' 6=8 e I J8 J O + % s ~ 3# 9J % _ ! F V M ' ) $ )

' ) % &8 • O " # ) ! " 6$ 9* $ ) 6I 6(n ( 9J' G ' ) 5" % 6- ) • ƒ s &' G > ( c &

' ) (R ) n! > V M • " %) ' ! ' ƒ s ) & " ) #! 9J' G

> h 6f & 6- ) V G ) x SQL>ALTER SESSION SET sql_trace=TRUE;

e(R ) € * " G 9J > h 6(n t " # $x

BACKGROUND_DUMP_DEST Xác nh n#i t c a trace file ALERT USER_DUMP_DEST Xác nh n#i t o trace files

(54)

Ch ng DATA DICTIONARY, VIEWS VÀ PACKAGES

6.1.DATA DICTIONARY VÀ VIEWS

6.1.1 Data Dictionary

@ ' 8 S h $ ) J ! P O y ) ' ) e> J

#- ! n! " 9J " Y ^ F ) ' # " ) * @ ' 6(n &' G ! 5 ' ) 5" &'

@ ' ' )c# " ) ) =# b

@ ' 6(n s 6- ) ! #V % s ) g

i@ @ G ' : ) ) N @@:j

@ ' 6f ' ) ! u C1 ' W u k @ ' ' )c# '& x

Q

@ ' r Y

T3 9ƒ K @ ' ' )

Base tables

2 ) ' ) ' 6(n M" S " ) > ' ) " i )

j X- ) b " ) J8 ' ! W - P ( % ) h

! " ) J8 ' B ) J " ) 6o 6(n H '" 9J 6(n #o '" r+ Fx t > h M O * " ) > ' ) )IND$ 6h 6(n " ) 9I " M 6o 6(n ) g ' ) • 'f O8 " ) ' ) ) OBJ$ 6h 6(n " ' ‡ 6o 6(n ) g ' )

% ) h ^ F ) " = ' " ( INSERT•UPDATE• 8DELETE 6h 6] - ) ) ' ) " ) #- " s ! )'& S ) AUD$ i[ # 4# ! P % h# v )j

Data Dictionary Views

@ ' Y 6(n &' " = > ' ) G ! ') E" Y J8 ) #o 9J ] ) n! " ) > ' ) " eh A J ) M O " ) J8•

" ' (R ) 6(n &' " ' 8# ( ) Z )

(55)

6.1.2 Data Dictionary views

T3 9ƒ @ ' Y

@ ' Y 6(n ! = J# '& Z " ) ( ) s ( ) " #Z 6- % " E" '& ' Y J8 6(n ! = " ! 6P ) % "

$ •f h¡ { 82(%

E" Y > ! 6P ) USER Z ) 9I " ' ‡ ' W R r+ Fx

USER_TABLES ƒ Z ) 9I " ) b W R

$ •f h¡ { '

E" Y > ! 6P ) ALL Z ) 9I " ' ‡ > h ! W R • ' )c# " 6$ (n ) ' W 6> 9J " 6$ (n ) % " #J W 6(n )" 58I

8 ! r+ FxALL_TABLES ƒ Z ) 9I " ) #J W R > h !

$ •f h¡ { B'

E" Y > ! 6P ) DBA Z ) 9I " ' ‡ > ' ) E" Y J8 J P ' 1- W O %† „ ) > h M # 6(n ) ' ) " Y DBA 6> 6(n O! 58I SELECT ANY TABLE

, “ l m |€ ‘ l m rž

$ rž ™ •

DICTIONARY DICT_COLUMNS

2 ) )

DBA_TABLES DBA_OBJECTS DBA_LOBS

DBA_TAB_COLUMNS DBA_CONSTRAINTS

2 ) * " 6$ (n ) b W (x • E' # • E' •

DBA_USERS DBA_SYS_PRIVS DBA_ROLES

2 ) 9I #Z 58I b W

$ rž ™ •

DBA_EXTENTS DBA_FREE_SPACE

(56)

DBA_SEGMENTS DBA_ROLLBACK_SEGS DBA_DATA_FILES DBA_TABLESPACES

2 ) 9I O B

DBA_AUDIT_TRAIL DBA_AUDIT_OBJECTS DBA_AUDIT_OBJ_OPTS

E" ) % h#

r+ Fx eh O8 " ) ) ' ) S h • > h 9O ' ) E" Y DICTIONARY 'f DICT_COLUMNS

SVRMGR>SELECT * 2> FROM dictionary

3> WHERE table_name LIKE ’%TABLE%’;

TABLE_NAME COMMENTS

- - ALL_ALL_TABLES Description of all object and relational

tables accessible to the user

ALL_NESTED_TABLES Description of nested tables in tables accessible to the user

ALL_OBJECT_TABLES Description of all object tables accessible to the user

ALL_PART_TABLES

ALL_TABLES Description of relational tables accessible to the user

ALL_UPDATABLE_COLUMNS Descriptionofallupdatablecolumns

DBA_ALL_TABLES Description of all object and relational tables in the database

DBA_NESTED_TABLES Description of nested tables contained in all tables

DBA_OBJECT_TABLES Description of all object tables in the database

J“ }s } k rž

% &' • ! 9J' ' x SYS9J &8 " ! x ') 59J ! ') 6h &' " ' Y ) (R )• " ! J8 \# ' ) ( #F x %ORACLE_HOME%\RDBMS80\ADMIN

k kl †l

CATALOG.SQL ! a ) 6h &' " Y s " i ) j b

E" Y J8 ƒ 6(n &' ' 8# i#- % " 9* b ' ‡ 6(n a ) 6h ! ' ‡ j ( ) Z ) 6h A J ) 9O " S 6> ! J8 ~ )y * " ! % " 6h &' " Y 9J " 6$ (n ) % " ! F 9F ' " + ) • ' % h# • ' " + CM!' 9J #!' • ! STANDARD.SQL 6(n )y ' ) 6> 6h &' " #2 (R ) <:w : = ' H

r+ Fx ! &' #€ ) ' ! ' K J# v > BITANDx

(57)

k f †l

CATPROC.SQL ! a ) 6h &' " J# <:w :• " ! % ) <:w : ^ F ) ' ) RDBMS X)'J •CATPROC.SQL ! ~ &' E" Y # - ) % "

6.1.3 Sripts qu n tr

E" ! 6(n 6f ' ) ( #F x%ORACLE_HOME%\RDBMS80\ADMIN E" ! J8 6(n ! = ># 9J 6f ' ) S ) G )

E" 58 9I > ' ) !

7 z• ™ •

E • E" ) E ') 9J S h

@ # • < P % "' i ! G ' j b " ! % ) ' ) < • ! < P = ! % ) 6o 6(n #o '" 9J 6> ) )>

W • E" Y 9J + ' )

6.2.STORED PROCEDURES VÀ CÁC PACKAGES CHU'N

6.2.1 Gi i thi u chung

' ! ' 9J " ! % ) J " 6$ (n ) ' ) • 6> J ! n! " 6'& #o <:w : 6h s #- Z { ) J' 6>

' ! ' ' )c# " ! ' i b F j• G ' i J#j 9J " ! % ) 6(n )-! J #- ! ') # i6 ( ) j

' ! ' > h 6(n &' 9J U " CREATE9JDROP

T3 9ƒ ' ! ' 9J " < % ) H

› … pk r} f r} r

E" ' ! ' 6(n &! 9J' !'' • ' 6> > h ) # * M O 6g

% s b F

e # ' 'J ' • ){ % ) ' " ! s ! 9J' #J ! ) " b F 9J J# ) ' ! 6o 6(n ) O!

E ' ! |! I > h a ) ^ F ) " ' b ' ! ' 6h s

6.2.2 Stored procedures

(58)

6(n • > ƒ 6(n )" 9J > h s s ! #J % ) P ! & 4# O Z #- P J'

.^ F ) ' ! ' • > h &! s ! 9J' ) h Z - = : ) $ ) ( J " J# v > ` b (UPPER 8SUBSTR

E" G ' 9J ! ' ' ! |! ^ F ) # $ (* & ) # $ 9J' iINj 9J # $ iOUTj 'f „ ) > h ^ F ) # $ 9S 9J' 9S iIN OUT) ' #f • " # $ 6(n M" 6- 9J'IN

6.2.3 Packages chu)n

1- ! % ) ) (R ) )c# ! P x ! G ' i! P 6f ~ )y J ! P % "'j 9J ' i! P = j E B ) 6(n ( ) ' ) a )

#-< P ! G ' J ! P ) ' ! 9* " Z ) F ) < P J8 Z " R % "'• " % h • • \ )• M ! ' • ' • 9J " % "' J# 6h ^ F )

< P ' J ! P J 6f F h i #! # ' j b " % "' ' ) ! P ! G ' E Z { ) b ! % ) „ ) ( ) s ( ' ! ' 1- % ! % ) 6(n • ! % ) 6> > h 6(n ^ F ) I Z ) F ) % " • > #- n + *

O % ^ F ) ! % ) J ) P 6P )y ! % ) • 'J - ! % ) ƒ 6(n &! 9J' ' ) - *

T3 9ƒ < % ) ' )

6.2.4 Gi i thi u m t s packages chu)n Oracle cung c p

) O! #- $ ! % ) H • ) % &' x

DBMS_LOBx ) O! " b F ' ! |! J# % h BLOB 9J CLOB• 6(n ) g ' ) G ! ! ')

DBMS_SESIONx ) O! " = : ' ( ALTER SESSION,

SET ROLE• ! % ) J8 6(n ) g ' ) G # 59J!

DBMS_UTILITYx Z " b F + • 6(n 6f ' ) G # 59J! DBMS_SPACEx ) O! " ) 9I % ' ) $ ) b )#

DBMS_ROWIDx ) O! " ) 9IROWID

DBMS_SHARE_POOLx ( 9J U p " ) > ' ) !''

,k xk r $ p „ fk xk r ™ •

DBMS_SESSION SET_ROLE 7+ '& s l' b

SET_SQL_TRACE ! 6- ~ 3# s

(59)

,k xk r $ p „ fk xk r ™ •

CLOSE_DATABASE_LINK e> ) %

UNIQUE_SESSION_ID 9I #o O " '

6 ) ' *

IS_ROLE_ENABLED [" M # ' > 6(n %+ '& ' ) ' % )

IS_SESSION_ALIVE [" M # ' > ~ % ) SET_CLOSE_CACHED_OPEN_CU

RSORS

Q 'f _

close_cached_open_cursors FREE_UNUSED_USER_MEMORY

/ ! > ) 9a ) - * % ) ~ ^ F )

DBMS_UTILITY ANALYZE_SCHEMA < = + " ' ‡ ' ) # (x G ' • ! ' • ! % ) •

)) •

COMPILE_SCHEMA Q " ' ‡ ' ) #

DB_VERSION [" ! b

DBMS_ROWID ROWID_INFO ) 9I ~ )

DBMS_SPACE UNUSED_SPACE ) % ) ) % ) ^ F )

FREE_BLOCKS E" ' % V

DBMS_SHARED_P OOL

KEEP :( " ' ‡ ' ) !''

UNKEEP ( ) " ' ‡

SIZES 7+ (* - * ' ) !''

DBMS_SQL OPEN_CURSOR 9I $ ' i @ # j

PARSE < = + =

BIND_VARIABLE Q #- ) "

BIND_ARRAY Q #- ) " # )

EXECUTE Function CM ) '

EXECUTE_AND_FETCH s 9J O8 9I " ~ )

FETCH_ROWS :O8 9I " ~ ) b #- '

COLUMN_VALUE :O8 9I b

-IS_OPEN [" E ' 6o # (

CLOSE_CURSOR e> ) ' 9J ) ! > ) - *

LAST_ERROR_POSITION 9I V s = :

LAST_ROW_COUNT 9I $ (n ) ~ ) O8 9I

LAST_ROW_ID 9I #o ~ ) M^ kROWID

LAST_SQL_FUNCTION_CODE 9I #o J# :

6.2.5 Package DBMS_METADATA

(60)

DBMS_METADATA J ! % ) #* ] )• > ' ! |! s " ' " @@: ' ‡ ' )

< % ) J8 J# 6(n 9* " • M • Y • ! % ) • G ' • ! ' • )) • ' 8# • 9J 8!

DBMS_METADATA > " J# x

DBMS_METADATA.GET_DDLi' ‡ m8! • # • # j DBMS_METADATA.GET_XMLi' ‡ m8! • # • # j r+ Fx

SELECT DBMS_METADATA.GET_DDL(‘TABLE’, ‘EMP’, ‘SCOTT’) from dual;

CREATE TABLE "SCOTT"."EMP" ( "EMPNO" NUMBER(4,0), "ENAME" VARCHAR2(10), "JOB" VARCHAR2(9), "MGR" NUMBER(4,0), "HIREDATE" DATE, "SAL" NUMBER(7,2), "COMM" NUMBER(7,2), "DEPTNO" NUMBER(2,0),

CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO") USING INDEX PCTFREE 10 INITRANS MAXTRANS 255

STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS MAXEXTENTS 2147483645 PCTINCREASE

FREELISTS FREELIST GROUPS BUFFER_POOL DEFAULT) TABLESPACE "USERS" ENABLE,

CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO") REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE NOVALIDATE ) PCTFREE 10 PCTUSED 40 INITRANS MAXTRANS 255 LOGGING

STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS MAXEXTENTS 2147483645 PCTINCREASE

FREELISTS FREELIST GROUPS BUFFER_POOL DEFAULT) TABLESPACE "USERS"

SELECT DBMS_METADATA.GET_XML(‘TABLE’, ‘EMP’, ‘SCOTT’) from dual;

<?xml version="1.0"?> <ROWSET>

<ROW> <TABLE_T>

<VERS_MAJOR>1</VERS_MAJOR> <VERS_MINOR>0</VERS_MINOR> <OBJ_NUM>5543</OBJ_NUM> <SCHEMA_OBJ>

<OBJ_NUM>5543</OBJ_NUM>

<DATAOBJ_NUM>5543</DATAOBJ_NUM> <OWNER_NUM>25</OWNER_NUM>

<OWNER_NAME>SCOTT</OWNER_NAME> <NAME>EMP</NAME>

(61)

<MAXEXTS>2147483645</MAXEXTS> <EXTSIZE>128</EXTSIZE>

<EXTPCT>0</EXTPCT>

6.2.6 Package dbms_redefinition

< % ) J8 ) O! K; b F ' ! |! t ^ " ' ‡ ' CAN_REDEF_TABLE

START_REDEF_TABLE FINISH_REDEF_TABLE ABORT_REDEF_TABLE SYNC_INTERIM_TABLE

6.3.THÔNG TIN V2 CÁC STORED PROCEDURES

7 ( " ' ! ' ! % ) • ƒ s 6- ) ( & & ) " b > J VALID 8INVALID

VALIDx ' ! ' ! % ) > & ) " JVALID > 6o 6(n 9J % ) > V M J8• > ` J ) ' ^ F )

INVALIDx J & ) " )(n & 9* & ) " VALID ' ! ' < % ) 9€ ~ V % J8• ( h ^ F ) 6(n )

EB ! "! 84 P & ' ! ' x

ALTER PROCEDURE [schema_name].<procedure_name> COMPILE [DEBUG]; r* x

schema_name tên schema ch a procedure c n biên d ch l i procedure_name tên c a procedure biên d ch l i

COMPILE ch nh yêu c u biên d ch l i procedure

DEBUG ch nh ch #ng trình biên d ch mã l nh PL/SQl c a procedure s+ sinh mã l nh phù h p ch #ng trình PL/SQL debugger có th &c User có th s d ng ch #ng trình dị tìm g, l i cho procedure r+ Fx ALTER PROCEDURE henry.close_acct COMPILE;

( ) s ( 6$ 9* ! ' • B ! "! 84 P & ' G ' > & )x ALTER FUNCTION [schema_name].<function_name> COMPILE [DEBUG]; r+ Fx ALTER FUNCTION merriweather.get_bal COMPILE;

e$ 9* ! % ) • 84 P & „ ) ( ) s ( ) > 4# #- ] ) J ! % "' … S ) ! P b ! % ) ƒ 6(n &

EB ! "!x

ALTER PACKAGE [schema_name].<package_name> COMPILE [DEBUG] <PACKAGE | SPECIFICATION | BODY>;

E" % "' ] ) ' ! |! 84 P & ! P SPECIFICATION ! P BODY 'f J & ! P

(62)

ALTER PACKAGE blair.accounting COMPILE BODY;

eh M" 6(n & ) " b " ' ! ' • > h s 9O s ' 8DBA_OBJECTS

SVRMGR> SELECT object_name, object_type, status

2> FROM dba_objects WHERE object_name like ’DBMS_%’ OBJECT_NAME OBJECT_TYPE STATUS

- - -

DBMS_ALERT PACKAGES VALID

DBMS_ALERT PACKAGES BODY VALID

DBMS_ALERT_INFO TABLE VALID

DBMS_APPLICATION_INF PACKAGES VALID DBMS_APPLICATION_INF PACKAGES BODY VALID

DBMS_AQ PACKAGES VALID

DBMS_AQ PACKAGES BODY VALID

T'f „ ) > h ^ F ) DESCRIBE6h O8 ) SVRMGR> DESCRIBE dbms_session.set_role procedure SET_ROLE (ROLE_CMD VARCHAR2); svrmgr> describe dbms_session

packages dbms_session is -

OVERVIEW

This packages provides access to SQL "alter session" statements, and other session information from, stored procedures

- PROCEDURES AND FUNCTIONS

procedure set_role(role_cmd varchar2); Equivalent to SQL "SET ROLE " Input arguments:

role_cmd

This text is appended to "set role " and then executed as SQL

procedure set_sql_trace(sql_trace boolean);

Equivalent to SQL "ALTER SESSION SET SQL_TRACE " Input arguments:

sql_trace

TRUE or FALSE Turns tracing on or off

procedure set_nls(param varchar2, value varchar2);

(63)

Ch ng QU N TR CONTROL FILES

7.1.CONTROL FILES

7.1.1 Gi i thi u control file

E' ' G J G ) & ) ! = 6(n ^ F ) ' % &' 9J J #- "

1V % 6(n MOUNT i)_ j 9* #- • " ) ' ) ' ' G ƒ

6(n 6y • S 6> M" " G 9J " ' ' ') G

E' ' G 6(n ! F 9J' ' ) $ 5" ^ F ) 9J > & ) " ` J ) i j #V % 6(n OPENi# j 6(n MOUNT ()_ j 9*

E' ' G ) O! " ) #- " 6c ) O ' ) 6(n ^ F ) ' ) 5" % ! F i '9 8j

1V ' ' G & #- R h# t ! F 9F ' #- 6o > #- ^ F ) ' ' G " % " ƒ % ) h ! * ' ' G 6>

7.1.2 Cách th3c :t tên control file

4 ' ' G 6(n M" ' ) # $ CONTROL_FILES b ! # G b " ' ' G 6(n 6f ! = " O ! H8 i,j ! F 9F ƒ # " ' ' G 9J O8 " ) S 6> 6h > h I % h '& 6- ) b ' ) 5" '& 6- )•

„ ) ƒ ) & " & ) b

eh # ' 'J • #- P + O K ' ' G 9J 6(n 6f & V % " E" ' ' G 6(n 6f % " ' ' > h ! = A J )

4 b E' ' G 6(n 6f %•# 9* b ' A *• ( x CTL<n><database_name>.ORA

r* x

n s th t c a control file

database_name tên c a database

' ) ! # G • " b ' ' G 6(n 6f ! = " " O ! H8 r+ Fx

control_files = (“C:\ORANT\DATABASE\CTL1KTKB.ORA”, ”C:\ORANT\DATABASE\CTL2KTKB.ORA”)

7.1.3 K t h?p nhi*u control files

7 &' • > h ^ F ) a ) B I ' ' G ) t … " ' ' G ' ) # $ % &' CONTROL_FILES &' 9J ! O

" " G #V % &'

% "' ^ F ) + O K ' ' G E" ' ' G 6(n 6f ) " ] 6g % " 6I ! ~ ) s $ X #- ' ' G p )• > h ' |! & G J8 c % 6- ) &

eh 4# #* #- ' ' G 'f 6] $ (n ) „ ) ( 6f " ' ' G • s ' " (* x

'Y

(64)

.^ 6] 'f 4# #* # $CONTROL_FILES9J i > 6(R ) € j ( ) Z ) 9* " ' ' G

7 6- ) &

7.1.4 N i dung c8a control file

E" ) Z ' ) ' ' G ' )c#x

4 9J " i G ' j

4 9J Z " G • " ' ') G " ! ' )

X o R ) ( ) Z ) B &'

/ " $ b ') R

2 ) 9I %!'

E" ) ^ i ') ' 8j

E" ) ' ( b + l '9 )

T3 9ƒ X- ) ' ' G

E' ' G > h 6(n J# '& + x E> h " ^ F ) i j

7 ) h " ^ F ) i j

7.1.5 Các tham s nh h ng t i kích th c c8a control file

E> #- $ # $ $ ) * %+ (* b ' ' G MAXLOGFILES

MAXLOGMEMBERS MAXLOGHISTORY MAXDATAFILES MAXINSTANCES

E" ' ' G 6(n M" s 6- ) s ' " # $ % &' & R h# &' ! x

CONTROL_FILES = (“C:\ORANT\DATABASE\CTL1KTKB.ORA”, ”C:\ORANT\DATABASE\CTL2KTKB.ORA”) G %•# ' 6(R ) € 6(n 6f ' ) # $ &'

E" # $ 6(n t ' ) > ( ) * ' ' G > h &' & " ' ' G 8 6] " # $ ' ) 6h > h { )• ) # %+ (* b

' ' G

(65)

7.2.QU N TR CONTROL FILE

7.2.1 T o m i control file

r &' #* ' ' G 6$ 9* 62 % J P o8 M| " $ )x

O " ' ' G b R 6I V 9J % ) > % ! b B )

# $ 6] #- I # $ 6(n ! 6$ 9* #J " # $ J8 6(n t ) S = CREATE DATABASE ( • MAXLOGFILES, MAXLOGMEMBERS, MAXLOGHISTORY, MAXDATAFILES, 9J MAXINSTANCES

r+ F• # $ 6] 6h % p M M ) 6- 9* #- ) > ' ) $ ) ( ) a )

> h &' #* ' ' G ' #- ) = : EB ! "!x

CREATE CONTROLFILE [REUSE] [SET] DATABASE database

LOGFILE [GROUP integer] filespec [, [GROUP integer] filespec]

{RESETLOGS | NORESETLOGS}

DATAFILE filespec [, filespec] [MAXLOGFILES integer]

[MAXLOGMEMBERS integer] [MAXLOGHISTORY integer] [MAXDATAFILES integer] [MAXINSTANCES integer] [ARCHIVELOG | NOARCHIVELOG] r* x

REUSE Cho bi t CONTROL_FILES có th c tái s d ng, ta không c n quan tâm t i tham s thu c lo i tu) ch&n

SET DATABASE Thay -i tên c a database L u ý: <Tên> DATABASE Tên c a database

LOGFILE danh sách tên c a redo log file groups MAXLOGFILES S l ng t i a redo log file groups MAXLOGMEMBERS S l ng t i a members m t redo

MAXLOGHISTORY S l ng t i a archived redo log file groups MAXDATAFILES S l ng t i a datafiles

MAXINSTANCES S l ng t i a instances có th k t n i t i database

ARCHIVELOG Thi t l p ch archiving l u tr redo log files

r+ Fx

CREATE CONTROLFILE

SET DATABASE prod

(66)

NORESETLOGS

DATAFILE 'datafile1' SIZE 3M, 'datafile2' SIZE 5M MAXLOGFILES 50

MAXLOGMEMBERS MAXDATAFILES 200 MAXINSTANCES ARCHIVELOG;

7.2.2 T o m i control file cho m t database ã có s7n

r &' #* ' ' G 6(n s ' " (* x

! " " G 9J ' ' ') G ^ F ) ' ) ' ) (R ) n! % ! • > h A J ) M" 6(n " " G J8 s 9J' ) ' ) ' Yx V$CONTROLFILE• V$DATAFILE• V$LOGFILE ' )

(R ) n! V • P $ )_ ) M" 6P8 6b " G 9J ' ' ') G X O %† #- ' ) $ " G ! u C1 ƒ % ) h % ! F & 6(n 9J ' 6> % ) h % ! F & 6(n

'Y i _ j > ) 6(n # s 'Y 6- ' #

' ) (R ) n! % ) h _ ' # 6(n o8 _ ' 6- IMMEDIATE 'f ABORT

' ( iQ % !j O " G 9J ' ' ') G b

! & 6- '#'

; &' #* ' ' G ) &' CONTROL FILES &' #* ' ' G • ^ F )

† y RESETLOGS #O O %† #- J' ' ' ') ) ' ! ' )

(R ) n! J8 P % ! F & " ' ') #O X)(n & • ^ F ) † y NORESETLOGS

? ' ( ' ' G #* &'

D ^ 6] " # $ ' ) ! # G #J > ^ F ) ' ) " ' ' G ' )c# # $CONTROL_FILES9JDB_NAME

s % ! F P ƒ p (* J8 ' ) (R ) n! % ) P ! % ! F X ' ' G #* &' > ^ F ) † y NORESETLOGS•

> h % ! F & 'J - ' ) (R ) n! † y ^ F ) J RESETLOGS• P t 4# #- † y JUSING BACKUP CONTROL FILE b

F J8 ƒ s % ! F & " ' 'f ' ') 'f G

d ! 9* ' ' G 9S &' X % ) s '9 > h '! 6- ' #

K X > ^ F )RESETLOGS ' ) B &' ' ' G • P ^ F ) 4# = ALTER DATABASE• 9* † y RESETLOGS

7.2.3 M t s l.i i v i Control Files

% s CREATE CONTROLFILE• > h )f! #- $ V x

Thi u file

% &' #- ' ' G 9J ^ F ) > 6h # • % h# ') 6h > M" 6(n > ) )3 % ) 6c ) O ) ' 9J ' ' G % )—r+ F

( G > %•# ' ' ( ) % ) > " " ' %•# X #- G 6o c & ' ) ' ( ) ( > ' ) ' ' G #* &'•

ƒ &' #- ! ' ' ) ' ' G 9* J MISSINGnnnni ' ) 6> J #- ' $ (* & ) ! ! = j

(67)

.^ F ) † y RESETLOGS ' ) = CREATE CONTROLFILE ƒ ' ! |! # #J % ) P * † y RESETLOGS e I J8 t > M O " ' ' ') ) ' ) & ) ` J )

.^ F ) † y RESETLOGS ' ) = CREATE CONTROLFILE6h _ - ! # a ) 9* † y RESETLOGS• G ( ) Z ) 9* MISSINGnnnn 6- t 6y 8OFFLINE

7 # > ^ F ) † y RESETLOGS• 9J MISSINGnnnn ( ) Z ) 9* G % ) 6- t 6y 'GG • ƒ % ) h M O 9J' G 6> ' ) (R ) n!

J8• ! Z G P 6(n U p iDROPj X6 lý l.i x y i v i l nh CREATE CONTROLFILE

)^ 9I #o V i " #o V M J 01173, 01176, 01177,

ORA-01215 'f ORA-01216j % $ )_ ) s #' 9J '! % &' #*

#-' ' G $ ) M O J ' ) = CREATE CONTROLFILE#J 54 #-G 'f > 6( 9J' G ( ) > 9€ ( > ' ) " ' ) (R ) n! J8• P ! % ! F iRESTOREj & " G 6o 6(n % ! (* i! + j 9J f! & " b F

(* i! + j ( k ^ F ) 6B ) " G

7.2.4 Hu- b@ Control Files

> h U p " ' ' G % p r+ F• s J8 % 6(R ) € * " ' ' G % ) ~ ! a n! E> #- I ( k J & O %† R h# J' „ ) P ! > + O J ' ' G

E" (* s

'Y i _ j

.^ & # $ CONTROL_FILES ' ) ! # G • M'" ' ' G „ 9J 9J' 6> ' ' G #*

l i% 6- ) & j

7.3.THÔNG TIN TR%NG THÁI CAA CONTROL FILES

> h M # 6(n " ) 9I ' ' G s ' Y > ' )

r+ Fx

SVRMGR> SELECT name 2>FROM v$controlfile; NAME

- /DISK1/control01.con /DISK2/control02.con rows selected SVRMGR> SELECT value

(68)

VALUE

- /DISK1/control01.con /DISK2/control02.con rows selected

V$CONTROLFILE_RECORD_SECTION Z " ) 9I " ' r+ Fx

SVRMGR>SELECT type, record_size, records_total, records_used 2> FROM v$controlfile_record_section

3> WHERE type=’DATAFILE’;

TYPE RECORD_SIZ RECORDS_TO RECORDS_US

- - - -

DATAFILE 180 30

1 row selected

(69)

Ch ng QU N LÝ REDO LOG FILES

8.1.SB D NG CÁC REDO LOG FILES

8.1.1 Redo log file

9 ^ F ) " ' ' ') G 6h ) # h #O #" ' ) l ' ') G ) & O " 6] ' ) GG S #- 9J )'& )

s !

l ' ') G 6(n ^ F ) % )f! s $ 9J # $ % ! F & " 6o '## ( ) ( % ! ) G l ' ') G t 6(n ^ F ) ' ) (R ) n! % ! F

9 P ! " ' " ' ' ') G b 6h " #O #" ) ' ) ' ^ F ) #- G O

T3 9ƒ ; X ># " ' ')

8.1.2 Online Redo Log Groups

:J ># " ' ) b " ' ' ') G 6(n )y J ' ' ') ) ' !

Q %) ' ! ' LGWR s ) 6c ) R " ) ( ) s 9J' " # # - a ) #- ) ' ! #- ) ' ! 6P8 ƒ ! F 8h ) ) ) ' ! ! '

9 • ) (R )• P + O K ' ' ') G ) ' ! 6h > h J

#-8.1.3 Online Redo Log Members

1V #- ' ' ') G ' ) #- ) ' ! 6(n )y J #- # # i J j

1V # # ' ) #- ># > #- $ Z s i ') # j ! = 9J " # # J8 > a ) #- %+ (* $ Z s 6(n )" #V % _ 6P )

9J' ') ) ' ! 6h > h ! = 6(n " ' ') G O $ ') # 6(n ( ' ) ' ' G 9J ' ) ! P b O " G

8.1.4 N i dung c8a Online Redo Log Files (Members)

' ') G ( " ' ' ~ 6(n )y J " ' 1V ' ' J #- ># " ) ' i9 ' 6] j• ' ) 6> #V ' 6f ( ) '

#-s 6] #- ' % - r+ F• % 6] ) " ( ) ' ) ) #! '8 • ƒ &' #- ' ' ( & 6] b )# ' %• ' % )# ' % 9J ' ( ) Z ) 9* 6] >

E" ' ( & " 6h S 6> > h " &' & " 6] ' )

(70)

• ƒ 6y " ) ' > ' ) " ' ' c "! " 6] J8 9J' " ' % ( ) Z )

E" ' ' 6(n ( ' ) - * # /0 1V % s '## #- ' • LGWR ƒ ) & " ' ' b ' 6> S " ' ') GG - /09J' #-' ' ') G • 9J )" #- $ # ) # iSCNj ' ' 6o 6(n

'## 6> E % " ' ' - ' 6o 6(n ( 'J 6g

! ' #* 6(n ) "'x ' '##

E" ' ' > h 6(n ) 9J' ' ' ') G (* % ' ( ) Z ) 6(n '## ' ') GG 6P8• 'f % ' '## • LGWR ƒ 6H8 O " ' ')

' ) ' ') GG ' ' ') G • ) % ' ' > h ( 6(n '## 6h % P • > h % ! F i ' %j & " 6] J8

8.1.5 Active Inactive Online Redo Log Files

& #V #- R h#• t ^ F ) #- ' ) $ " ' ' ') G 6h ( " ' ' > ' ) ' ') GG ' ') G 6> & ) " ` J ) ' ) • > 6(n )y J ' ' ') G

E" ' ' ') G P ' % ! F 6(n )y J ' ' ') G " & • " ' ' ') G % ) P ' % ! F 6(n )y J

9

7 6f 6- )• ƒ % ) h " ^ F ) ) 6• " ' ') G ' * % 0lE ( " - ) b > ' ) (R ) n!

9 )• % ' ' ') G $ a ) 6(n I 6P8• ( G ƒ 6(n ! F s 6$ 9* G 6P

8.1.6 Thi t l p Redo Log Files kh i t o

r % &' 6P ! n! " ' ' ') G ' )c# " ) ' ! 9J " # # 6(n s ' ) 5" &'

E" # $ (* 6=8 M" " ) * & 9J $ (n ) b ' ' ') G x

# $MAXLOGFILES ' ) CREATE DATABASE M" $ (n ) $ " ' ' ') ) ' ! $ (n ) $ 'MAXLOGFILES J255

# $ MAXLOGMEMBERS ' ) CREATE DATABASE 58 $ (n ) $ " # # > ' ) #V ) ' !

# $ % &' LOG_FILESM" $ (n ) $ " ') ) ' ! > h 6(n # ' ) & R h# R / " J8 % ) 6(n 9(n 5" ) " MAXLOGFILES*MAXLOGMEMBERS

8.2.LGWR, LOG SWITCHES VÀ CHECKPOINTS

(71)

8.2.1 Redo Log Buffer Background process LGWR

ƒ P s ) & " 6] 6$ 9* > ' ) ' ') GG l ' ') GG 6(n ^ F ) ' % h M' 9~ ) ' 6>• " ' ƒ 6(n I LGWR ) 9J' #- ' ) " ' ' ') ) ' ! )y J ' ' ') ) ' ! R i j '

" $ ) x

7 '## #- '

7 ' ') GG 6o 6P8

7 LGWR9(n 5" R ) # ' i ) =8j

(* % DBWR ) " ' % 6] ' ) GG 9J' ' ) " G

E" # # ' ) #- ' ') ) ' ! 6(n LGWR ) 6> 9* a ) #- - ) E ' % ) > % " ) " # # ' ) #- ') ) ' ! #J t > s % " ) " # # " ') ) ' ! % "

8.2.2 Log Switches

LGWR) " ' ' ') G #- " P s• Z J #V % ' ' ') ) ' ! 6(n ) 6P8• LGWR ƒ & 8h ) ) ) ' ! ! ' ' ' ') G $ a ) 6(n ) 6P8•LGWR ƒ & 9I ' ' ') ) ' ! 6P 9J & _ 6P 5" )

:') Y J s % M % LGWR S ) ) #- ' ' ') ) ' ! 9J 8h )

) ' ' ') ) ' ! % " „ ) > h s " ') Y \ ) 1V % M ') Y • LGWT ƒ ) ') ) ' ! #* 9J > )" #- $

8 O 6h M" 6(n " ' 9S ( )

1V % M s % ') Y 6c ) R #- s % %!' „ ) ƒ 6(n % &'

8.2.3 Checkpoints

7 > %!' 3:

O " ' ) GG 6o 6] • + ' R h# M %!' • ƒ 6(n Q %) ' ! ' DBWR) G

Q %) ' ! ' CKPT ! ! P b " G 9J " ' ' G

E %!' > h M 6$ 9* O " G ' ) 'f „ ) > h M 9*

#- G F h

E %!' M ' " $ ) x 1V % > ') Y

7 #- 'Y #- 9* " 6- S 6- '

[ ' ( R ) 58 ' ) " # $ % &'

LOG_CHECKPOINT_INTERVAL9JLOG_CHECKPOINT_TIMEOUT > 84 P s ! b

2 ) 9I %!' 6(n ( ' ) Alert file ' ) (R ) n! " # $ % &' LOG_CHECKPOINTS_TO_ALERT6(n 6f JTRUE rJ )(n & 9* ) " FALSE

8.3.LÊN K HO%CH SB D NG REDO LOG FILES

8.3.1 Xác nh s l ?ng Online redo log files

eh M" $ (n ) " ' ' ') G ^ F ) ' ! a n! 9* P ! % h# 9* I P % "

(72)

' > " ) ' ! ` a ) ' LGWR r+ F• % " ) ! ) ' ) G Alert file ' LGWR (R ) M 84 ! R #- ) ' ! ' 9€ ( % B 6(n %!' • 'f

' ) ' ! 9€ ( 6(n ( i j B J8 J B P 4# #* " ) ' !

1f a ' ! |! ^ F ) I ) ' ! 9* $ (n ) # # ' ) > J % " • 9€ $ )_ ) M=8 s ) #- O = 6$ i $ (n ) " # # ' ) " ) ' ! J \ ) j

8.3.2 N i :t Online Redo Log Files

7 ^ F ) 6c ) R I ' ' ') G • 6f " # # b #- ) ' ! " ! P 6g % " 1- I ( k J % #- # # J' 6> % ) ` a ) i j #J " # # % " J ` a ) „ ) % ) h 'Y 6(n

r " " ') G 9J ' ' ') G " ! P 6g % " • > h J# ) # * M ) 6- ) " %) ' ! ' ARCH9JLGWR

E" G 9J ' ' ') G 6f " ! P 6g % " 6h ) # * M ) 6-) LGWR 9J DBWR & #O G 9J ' ' ') G ' ) (R )

n! p ) ] 6g

8.3.3 Xác nh kích th c cho Online Redo Log Files

7+ (* $ h b #- ' ' ') G J ;K ~ %+ (* $ † - 9J' I J E" # # - " ) ' ! % " > h > " %+ (* % " •

4 6f %+ (* ) $ ) ) " # # J8

r ^ F ) " ) ' ! > %+ (* % " t s #- " &# R % # $ 6] %+ (* b " # # ' ) (R ) n! J8• P &' " ' ' ') ) ' ! #* 9* %+ (* % " • c 6> '& p i #'9 j " ) ' ! „

1- $ $ ) ( ) * O b " ' ' ') G x $ (n ) " ') Y 9J %!'

.$ (n ) 9J 6- * b " '

e- * b 9a ) % ) ) ( Z O!

8.3.4 L u tr redo log files

9 P ! 58 6f 6- ARCHIVELOG 6- NOARCHIVELOG

'

Ch NOARCHIVELOG

r* 6- NOARCHIVELOG• " ' ' ') G ƒ ) 6•#V % ' ' ') G 6o ) 6P8 9J M ') Y LGWR ƒ % ) ) 6• ' ') ) ' ! ' * % % B

%!' b ) ' ! 6>

(73)

Ch ARCHIVELOG

' ) (R ) n! 6(n ! 6- ARCHIVELOG• " ) ' ! 6o 6P8• #f a & ) " ƒ 9€ 6(n ( ) @' O " 6] ' ) 6I 6(n ) & ' ) " ' ' ') G • > h ^ F ) ! ( ) ! "! ' |! k i! % !j 9J > h % ! F & " 6o '## ' ) #J % ) n #O

T3 9ƒ :( 6- 0lET r X/

E> Z ( " ' ' ') G x

s ( \ ) i# 8j :( " ' ') G 6o 6P8 ' b

:( s 6- ) i '# 8j :( " ' ') G 6o 6P8 #V % M ') Y # $LOG_ARCHIVE_START ' ) ! # G M" " 6- ( J8

LOG_ARCHIVE_START = TRUE• s ( 6- s 6- )

LOG_ARCHIVE_START = FALSE• s ( 6- #

8.4 I2U KHI N L&U TR" SAU I V I PRIMARY/STANDBY

) O! I % h Y " ' ' ') ) ' ! s ' R ) i time-basedj ' ) O primary/standby• O " ' ') & ! # ƒ 6(n

( c 8h * r J8 ƒ % & $ (n ) " ' '

r s ( J 93 ' O " 6] ' ' ') &

! # 6(n ( eh I % h ( J8• P ^ F ) # $

ARCHIVE_LAG_TARGET r ! # $ J8 ' ! |! & • „ ) ( M" 6(n

% ' ) R ) 6(n ^ F ) ' (

8.4.1 Thi t l p tham s ARCHIVE_LAG_TARGET

7 ! # $ % &' ARCHIVE_LAG_TARGET, ƒ % h# ' %† R )

" ' ' ') b R 9J ! " " ') Y ' " I % x

/ ^ 6P • ') 6(n &' ) =8 9J 6> & #O # ) =8 6h ( ') 6g J8 % ' ) R ) n + m ƒ ( ) Z ) 9* ) " b # $ ARCHIVE_LAG_TARGET

E ') Z " ' '

# $ ARCHIVE_LAG_TARGET ' ) * & 9I R ) i + ' ) =8j #J

') P ^ F ) @' R ) ( % ) + M" \ ) % ' ) R ) ') Y # $ % ' J8 6(n ! 9* ) " % ' ) K ) =8

(74)

/ " K ( ) Z ) 9* % ) s Z { ) ') Y ) e=8 J ) " ! #f

> h 6f ) " ' # $ARCHIVE_LAG_TARGET ) % % ) ' )

6-' ( i j r+ F• # $ARCHIVE_LAG_TARGET > h 6(n ! 6h _

-" ') ! s ' " Y 9J ( ] 6g

ARCHIVE_LAG_TARGET J #- # $ 6- ) 9J > h 6] ) " b # $ J8 )

= ALTER SYSTEM SET

8.4.2 Các y u t nh h ng t i tham s ARCHIVE_LAG_TARGET

E> #- $ $ P 6(n M # M| % ! ) " ' # $ 0lET rCm:0/m 0l/C ] ) R ) Y iM # ( J R ) ( j " ')

P O s Y " ') % > 6P8

:(n ) > h ' #O % J# 6-

# $ ARCHIVE_LAG_TARGET ƒ % ) F ) % ') 6(n Y ' ) #- % ' )

R ) 5" )_ • ' ) (R ) n! " ' 6(n &' 9* $ 6- % ) 6I ( • % ' ) R ) )_ 5o ) i j ƒ 6( ) * & 6$ 9* ')

' ) & ) " ) t i j 9J ' ' % ) 6(n &' 3• % ' ) R ) • ') Y ƒ M 9J 6H8 9J ) O " ' '

' ) (R ) n! ARCHIVE_LAG_TARGET 6(n ! 9* ) " 5" O! „ ) % ) $ '

$ ) 9I #f O :J 93 $ ) F ! s " ') Y @' y ) " n! k 6h = ) ' O $ )

8.5.XÁC NH CH C L&U TR"

eh 6(n " ) 9I ( • > h ^ F ) #- $ " x

8.5.1 S6 d ng l nh Server Manager

E= J8 ' 6- ') b

r+ Fx

SVRMGR> ARCHIVE LOG LIST

Database log mode No Archive Mode Automatic archival Disabled

Archive destination ?/dbs/arch Oldest online log sequence 688 Current log sequence 689

8.5.2 S6 d ng thông tin data dictionary

„ ) > h ^ F ) ) ' ) " ' Y xV$DATABASE9JV$INSTANCE r+ Fx SVRMGR> SELECT name, log_mode

2> FROM v$database;

NAME LOG_MODE

- -

U15 NOARCHIVELOG

1 row selected

SVRMGR> SELECT archiver 2> FROM v$instance; ARCHIVE

- STOPPED

(75)

„ ) > h M # " ) " ) ' ! 9J " # # ) Y ' 8V$THREAD, V$LOG

E" ) P =#x

V$THREAD: GROUPS, CURRENT_GROUP#, SEQUENCE# V$LOG: GROUP#, MEMBERS, STATUS, SEQUENCE#, BYTES r+ Fx

SVRMGR>SELECT groups, current_group#,sequence# 2>FROM v$thread;

GROUPS CURRENT_GR SEQUENCE# - - -

2 689

1 row selected

SVRMGR>SELECT group#,sequence#,bytes,members,status 2>FROM v$log;

GROUP# SEQUENCE# BYTES MEMBERS STATUS - - - - -

1 688 1048576 CURRENT

2 689 1048576 INACTIVE

2 rows selected

' ) = 4 • ) " b - STATUS6(n h ( x

UNUSED t ' ' ') ) ' ! 9€ ( 6(n ^ F ) & ) " J8 ( ) Z ) 9* ' ' ') G #* 6(n 4# 9J'

CURRENT t \ ) ' ' ') ) ' ! ) 6(n ^ F ) X> „ ) )P# & ) " 6$ 9* " ' ' ') ) ' ! J8

ACTIVEx & ) " J8 Z ) 9* ' ' ') ) ' ! 9€ ) 6(n ^ F ) ( ) % ) ! J ' ' ') ) ' ! R

INACTIVE t ' ' ') ) ' ! % ) ~ P ' % ! F

eh M" b O " # # ' ) #- ) ' !• > h Z ) ' ) V$LOGFILE: GROUP#, STATUS, MEMBER

r+ Fx

SVRMGR>SELECT * 2>FROM v$logfile;

GROUP# STATUS MEMBER

- - -

1 /DISK3/log1a.rdo

2 /DISK4/log2a.rdo

8.6 I2U KHI N CÁC LOG SWITCHS VÀ CHECKPOINTS

8.6.1 Th c hi n log switches

:') Y 9J %!' J " s % M #- " s 6- ) #V % ' ' ') ) ' ! 6P8 • 9€ > h ! " " :') Y ) b )

SVRMGR>ALTER SYSTEM SWITCH LOGFILE;

' ) C ! ) N C1• J# ' " (* x ^ F ) Q % ! )

E y #

(76)

8.6.2 Th c hi n checkpoint

„ ) > h ! " " E %!' ) x SVRMGR>ALTER SYSTEM CHECKPOINT;

' ) C ! ) N C1• J# ' " (* x ^ F ) Q % ! )

E y #

E y :')G vv™L' %!'

8.6.3 i*u chDnh ng t quãng checkpoints

' ) (R ) n! ^ F ) " ' ' ') G * • > h I t & " )_ 5o ) 6$ 9* ' ' ') G 6> ) " # $x

LOG_CHECKPOINT_INTERVALx $ (n ) ' % i + ' $ ' % b I J j * O 6h s #- %!'

LOG_CHECKPOINT_TIMEOUTx ' ) R ) * O i + ' ) =8j 6h s #- %!'

8.7.QU N TR CÁC REDO LOG FILES

8.7.1 B5 sung online redo log groups

' ) #- 9J (R ) n!• > h P * &! 4# " ') ) ' ! " ') # # EB ! "!x

ALTER DATABASE [database]

ADD LOGFILE [GROUP integer] filespec [, [GROUP integer] filespec] ]

T3 9ƒ d Q] ) ' ' ') ) ' !

r* = • P t 9J 6(R ) € b " # # ' ) S ) ) ' ! F h / " b # $ GROUP 6(n y ( ) Z ) 9* #V ' ') G ) ' ! ' ) (R ) n! p

# $ J8• ƒ s 6- ) " ) " + n! ' ) C ! ) N C1• J# ' " (* x

.^ F ) Q % ! ) E y #

(77)

8.7.2 B5 sung online redo log members

T3 9ƒ K Q] ) ' ' ') # #

( ) s ( " ) ' !• „ ) > h 4# #* " # # ' S ) ) ' ! \ ) = : ALTER DATABASE [database]

ADD LOGFILE MEMBER [ 'filename' [REUSE] [,'filename' [REUSE]] TO {GROUP integer

|('filename'[, 'filename'] ) }

]

:( kx G 6(n t P %•# ' 6(R ) € 6P8 6b ' ) (R ) n! % ) > 6(R ) € • G ƒ 6(n M # ( 6(n 6f ' ) ( #F #f X G 4# #* 6o c & • P

4# 9J' † y REUSE

' ) C ! ) N C1• J# ' " (* x ^ F ) Q % ! )

E y #

E y :')G vv™0 :')G #

8.7.3 nh l i ch. cho redo log file

' ) #- 9J (R ) n!• P ! 8h " G ' ') * #- + % " • 6h # ' 'J Œ ) & J8• P s ' " (* x

_

' |! " ' ' ') G * #- 6 h# #*

l 6- #'

s ALTER DATABASE RENAME FILE6h 6] ' p ' ) ' ' G • p * #- 6(R ) € G #*

; & i: x ALTER DATABASE OPENj E= 6] G x

ALTER DATABASE [database]

RENAME FILE 'filename'[, 'filename'] TO 'filename'[, 'filename']

z ‡x < c & G 6(R ) € #* t

(78)

E 8h * B :')G / ' ! E y ') G ) ' ! ( ) Z )

8 6] G ' ) (R ) - +

8.7.4 Ng,ng s6 d ng Online redo log groups

eh > h 6] %+ (* " ' ' ') ) ' ! • > h 4# #* " ' ' ') ) ' ! 9J M'" p " ' ' ') ) ' ! 6o >

.^ F ) b ) 6h )( ) ^ F ) ' ' ') ) ' !x ALTER DATABASE [database]

DROP LOGFILE

{GROUP integer|('filename'[, 'filename'] )}

[,{GROUP integer|('filename'[, 'filename'] )}]

T3 9ƒ X)S ) ^ F ) ' ') ) ' !

' ) C ! ) N C1• J# ' " (* x .^ F ) Q % ! )

2 E 8h * B :')G / ' ! E y ') G ) ' ! ( ) Z ) E y :')G vv™@ '! :')G / ' ! QO# B

€ ‘ h y| ¡ lz ‡ x Š l f

1- P + O ># i) ' !j " ' ' ') G ) h U i '!j ) ' ! ) & ) "

7 U #- ' ' ') ) ' !• s O t U 9I #f ') #J ƒ % ) ! F k > • " G ƒ 9€ ~ 9J % ) M'" TeT

8.7.5 Ng,ng s6 d ng Online redo log members

( ) s ( " ') ) ' !• 6$ 9* " ') # # „ ) > h )( ) ^ F ) ^ F ) b ) 6h )( ) ^ F ) ' ' ') # # x

ALTER DATABASE [database]

(79)

T3 9ƒ X)S ) ^ F ) ' ') # #

' ) C ! ) N C1• J# ' " (* x .^ F ) Q % ! )

2 E 8h * B :')G / ' ! E y ') G ) ' ! ( ) Z ) E y :')G vv™@ '! :')G # QO# B

€ ‘ h y| ¡ lz ‡ x Š l |r|qr

7 ) h )S ) ^ F ) # # b ) ' ! #J > & ) " JVALID

X ) ' ! ) ' ) & ) " • P ! s ') Y 6h 8h ^ F ) ) #- ') ) ' ! % " (* % )( ) ^ F ) " # # b ) ' ! R

7 U #- ' ' ') # # • s O t U 9I #f ') " G 9€ % ) M'" I J

8.7.6 Xoá r.ng Online redo log file

' ) #- 9J (R ) n! " # # V • > M^ k \ ) " % &' & " ') G ) : 6h % &' & x

ALTER DATABASE CLEAR LOGFILE EB ! "!x

ALTER DATABASE [database]

CLEAR [UNARCHIVED] LOGFILE

{GROUP integer|('filename'[, 'filename'] )}

[,{GROUP integer|('filename'[, 'filename'] )}]

.^ F ) J8 „ ) ( ) 6( ) 9* 4# #* " ' ' ') G 9J M'" p " '

') G R

z ‡œ

(80)

Ch ng QU N TR TABLESPACES VÀ DATA FILES

9.1.C=U TRÚC CAA DATABASE

EO B ' )c# O B ') 9J O B k

EO B k ' )c# ! n! " ' ' G • ' ' ') G 9J " G EO B ') ' )c# " # ' ‡ ! • )# • M 9J ' %

T3 9ƒ EO B

9.1.1 Quan h gi a database v i tablespaces data files

rI #f ') • #- > h ! = p J I ! P )y J " ! $kqlrfk r

1- ! t -

#-1V ! > h Z #- I G - I J

! > h 6f & ) " ' 'GG ' ) B ) &8

X)'& S ! SYSTEM ! Z ' % )# ) > & ) " ACTIVE• " ! 6I > h 8h 9I & ) " 'GG ' ) B )

&8

E" ! „ ) > h 8h 6] & ) " vY v' 2Œ }„ kqlrfk r

eh I % h 9a ) % ) ) O! ! " 9J )" ' #V

r* 6f 6- ' 'GG ' " ! • > h 6] + ` a ) i 8j b " ' ) " !

(81)

T3 9ƒ ) ! 9J G

k k •lr

1V #- ! > h ' )c# #- I G • J " G - I J a ) 6h ( ' ) ! E" G > #- $ + O + x

1- G t - 9I #- !

9 > h 6] %+ (* b G ) % > 6o 6(n &' !• J# { ) + { ) 6- ) ' " 6$ (n ) > ' ) !

9.1.2 Quan h gi a segment v i extent blocks

' ! |! I t % ) ) 6g ) 6] %+ (* b " O B ( ') (x ! • )# • M 9J ' %

2r |r

1- )# J 9a ) % ) ) O! ! " ( ) Z ) 9* #- % h O B ') > ' ) #-! > h ! = J# #- $ '& )# + x

@ )#

M )# #!' )# l' % )#

1- )# F h J #- )# > h 6(n - ) I G -

#-! (Šr

CM J #- O! 6- ! = 9I #f ') ! ' b 1- M J ! n! ! " ' % 1V % h )# 6(n 58 ' )c# #- I M " 9*

)# • #- M t 6(n \# O #- G k k Bl x

e=8 J ( i ( k % ) ! J kj p O ' )

1- ' % ƒ ( ) Z ) 9* #- I ' % b I J ir+ Fx I J q 'Y • ' % I J ˜ % ˜ • K j 7+ (* b ' %

6(n M" # $ % &' DB_BLOCK_SIZE ) % 6(n &' Q ' % ' ) „ ) J 9J' p O

9.2.PHÂN LO%I CÁC TABLESPACES

(82)

1- )c# > + O #- ! J ! u C1• J ( " ) b $ ) X)'J • ~ > h 4# 9J' " ! % " • 6> J " ' v.u C1

! • Z b " $kqlrfk r2G2$(

E> ' ) O "

E Z ) 9I " ' Y • " ) g b ' ! ' • ! % ) • 9J " )) (* & ) <:w : ! ') #

E Z u C1 ' % )#

7 ) Z )(R a ) ' ) ! J8 #f a > h

T3 9ƒ ; @ )(R a ) 6f ' ) ! )

Y2G2$( $kqlrfk r E Z " ' % )# E Z " #!' )# E Z " )# E Z " M )#

9.2.2 Tablespaces read-only / read-write

$kqlrfk r rk}Y l

1F 6+ + b ^ F ) " ! v' i t 6y j J & " b F P

% s ' ( 9J ! F c #- ! P * % ) 6] i j b

% ) s ! " G \# ' ) ! v' 8• 93 " G > h 6(n 6f ' ) t 6y ( E@ l ] 6g q l1 iq vl 8j

1V % &' #* #- ! • $ ) ƒ &' ' #- ! > 6b 58I 6y 9J 58I ) > h 6] & - + ! J v' ) # 6I READ ONLY ' ) = ALTER TABLESPACE r J8 ƒ € * O " G

-! 6> ƒ 6(n 6f & - + J v'

E= ALTER TABLESPACE READ ONLY ƒ 6f ! 9J' 6- 8h !

i ' v' 8j 9J R ' O " ' 6> % B i '## 'f ' %j

E 6- 8h ! J8 ƒ % ) ' ! |! O %† #- ' " ) #* J' 6(n s ! )'& S ' % " ' R 9J 6] ' ) " ' %

' ) ! @' 6>• 6- 8h ! b ! „ ) ( ! v' 6$

9* " = #* b )(R a ) )'& S ROLLBACK % O " '

(83)

ef 6- v' ' ! % ) J# ( ) * & ) " 'GG ' b ! 6> E" GG G 9€ % ) h M O 6(n r 6( #- G ' ) ! v' 9J' 6- ' ƒ ' ! |! > h 6y ' ) G 6> L J8 9€ % ) h 9J' S ! ! ( ) Z ) 6(n 6f & 6- ' ! |! 6y 9J )

l v' ! % ) h ^ 6] eh ! ' ) #- v' ! •

(* P 6f & 6- ' ! J vY 6>• s ! ' ) ! c 6f & 6- v' ' ! 6>

@' " v' ! % ) ^ 6] „ ) % ) P ! s % ! > I P rJ „ ) % ) P ! ! F c & " v'

! • ' ' ) 6> % ) 6]

% ) h ] ) " G 9J' ! v' 8• ) % 6o 6f 6- ' ! J 'GG Q 93• % ] ) #- G • ƒ ! ! ! P )

' ) % 6> ' " ) ! J8 J % ) 6(n ! |! $kqlrfk r rk}Yž r

" 9* ! v' 8• 9* " ! vY • > h s " ' " 6y 9J ) 6>

„ ) > h ^ F ) # 6I READ WRITE ' ) = ALTER TABLESPACE 6h 6] & ) " ! v' J & ) " vY

9.2.3 Temporary tablespace / permanent tablespace

#!' ! 6(n ^ F ) 6h J ) ' " ' " _! M ! ' )

#!' ! % ) > O Z )# J' \# ' ) 6>

.' )# > h a ) 6(n ‚ ^ F ) % I ' " _! M ! a ) 6(n s 1- ' )# 6(n ^ F ) ' O " > s ' " _! M !

#-!

r ^ F ) " #!' ! ' ! |! = ) ' O s #V % > I ' " _! M ! 6(n s #- 9a ) * * 9J % ) ! a n! 9* %+ (* b -* ' ) b #"8 + ' )# - #!' ! 6(n &' 9J' ) R h# 6P b ' " _! M ! ' )# ƒ 6(n O! 4# 9a ) * 9J # - ) P ' * % %+ (* b )# ) ) \ ) 'f * ] ) $ %+ (* ( P ' s

O " ' " _! M ! b

E" ! % ) ! J #!' ! 6(n )y J " ! # ! E"

! # ! 6(n ^ F ) 6h ( ' )

9.3.QU N LÝ KHÔNG GIAN TRONG TABLESPACES

! O! ! " 9a ) % ) ) ' " M ! ^ F ) ! ( ) ! "! % " 6h O! ! " 9J ) ! > ) 9a ) % ) ) ( ) x

k " M ' i ' 8v# ) ! j

k " M ! i ' 8v# ) ! j

X) % &' ! • P s y ! ( ) ! "! k 9a ) % ) ) ƒ 6(n "! F ) ' ! 6> 6o y c • % ) h 6] ! ( ) ! "! k % ) )

9.3.1 Dictionary-Managed Tablespaces

' ) ! ( ) ! "! J8 ! ^ F ) ' 6h k " M b > ! S ) ' ) ' #V % O! ! " • ) ! > ) ^ F ) & #- M

(84)

' #f • ! ( ) ! "! k J8 ƒ 6(n "! F ) ' " ! > ' )

' ) " ! K 'f *# • t > #- ! ( ) ! "! 6> + J ! ( ) ! "! J8

9.3.2 Locally-Managed Tablespaces

Q4 & 6>• ! „ ) > h k " M b > ) #- # ! i" M& j ' ) S ) G S 6> M" 6(n & ) " b " ' % ' ) G J ) ^ F ) 6o 6(n ) ! > ) 1V #- ' ) # ! ƒ ( ) Z ) 9* #- ' % #- ># " ' % 1V % > #- M 6(n O! ! " • ) ! > ) " ^ F )• ƒ 6] ) " b # ! ' 6B ) ( & ) " #* b " ' % r 6] J8 ƒ % ) J# ! " " ) ' ) ' % ' % ) > ' " ! J' ' ) " b

' iX)'& S (R ) n! 6f " ) & #Z i5' j b ! j

:' 8v# ) ! > #- $ ( h# ' 9* ' 8v# ) ! Jx k F - " M " " ' " k % ) ) ' % h 58 r J8 > h M % ^ F ) ! ( ) ! "! ' 8v# ) ! ^ F )

8 ) ! > ) % ) ) J % b " ' " ^ F ) ) ! > ) % ) )

' ) ' % )# '

k F - " M #- " s 6- ) " 9a ) % ) ) ) ! > ) I %I 9* e I J8 J P % s ) n! O " M V

7+ (* b " M 6(n k F - > h 6(n M" s 6- ) $ ) 1f % " • O " M > h > a ) #- %+ , ( ' ) ! ( ) ! "! ' 8v# )

!

1 6I LOCAL ' ) ! P EXTENT MANAGEMENT b = CREATE TABLESPACE ƒ t … ! ( ) Z k % ) ) x

r* " ! # ! 9J #!' ! • > h ^ F ) # 6I EXTENT MANAGEMENT LOCAL

' ) ! • ! ( ) ! "! k J8 9€ ( 6(n "! F ) ' ! u C1 X "! F )• $ ) ƒ ! " V Kd ;

9.4.THI T L0P TR%NG THÁI CHO TABLESPACES

9 > h ! & ) " ' " ! J' i > h ^ F )j 'GG i% ) h ^ F )j )'& S ! u C1 #V % # ! u C1 & ) " ' #V % 6(n # 93 ! ^ F ) "

' ) '

1- ! ) (R ) 6- ' % 6>• " ' ) > J ` J ) 6$ 9* " • > h 6f 6- 'GG ' ! x

7 J8 #- ! P b ƒ % ) h M O 6(n • ' ) % ! P ~ & 9€ > h M O (R )

s 'GG ! % % ! i#f a 9€ > h % ! )

% ) &8 9J " ! & ) " ' j

z ‡x % ) h 6f 6- 'GG ' ! > > Z " ' % )# ) 6(n ^ F )

~ &••l r kqlrfk r

7 #- ! 6(n 6( 'GG • ƒ % ) ' ! |! s " = : > # * " ' ‡ ( ' ) ! J8 ( & " ' % ( ) Z ) % s = : ' ) #- ' % )# % " > ' ) ! u C1 93 J ' % )# > ' ) ! 6(n 'GG > ! 6(n 6( 9I '

(85)

t > h 6( #- ! J ' ' ) + #J > 6(n &'• % ) h 6f ' ' ! ' ) #- % " 6(n r J8 6(n ) "# " " )

> ' ) '

s 6- ) s 8h 6- S ' J 'GG 6$ 9* ! #V % M s $ $ ) r+ F (x @Qq )f! V

9.5.TRAO EI CÁC TABLESPACES GI"A DATABASES

> h ^ F ) Z { ) !' ! 6h 8h #- ! P b

#-) #- % " r ' 6] " ! ) " J O + 'x

r 8h S $ ) M^ k s i : < N ' ' ! ' )

8 # j ) J b $ ) % ' i Y ' ) ) # j

E ! % ' i Y ' j 9J " - $ ) X&! " S " % ' ) =# i Y ' j

:( " b $ ) : < Y ' # GG

E ) O! ' " % " J ) 'f )(R ^ F )

-@ 8h ) ' 6] " ! ' ! |! 8h

> ) 9J " " 8h % " ( M!' w#!' ' w' 6$ 9* a ) #- • @' ' 6] " ! t 6~ p ! ' |! " G c +

n! ) 9I O B b ! 9J' #* E> h ^ F ) ! ( ) ! "! ' 6] " ! 6h 8h " M • ' 6>• 6h " " &' & i j " M•

> h s ) J8 6h &! ' ) " )

9.5.1 M t s h n ch vi c trao 5i tablespace:

@ ) c 9J 6+ ! 6(n &8 a ) #- I ! P Z ) i Y ! G' #j r+ F• > h ' 6] " ! ) &8 I J ' • 'f ' 6] " ! ) " &8 I J X

8 8• % ) h ' 6] " ! ) WX ' 9* " &8 X

@ ) c 9J 6+ ! > a ) #- %+ (* b ' %

@ ) c 9J 6+ ! ^ F ) a ) #- ! %k s ^ F ) ' ) i ' j

7 ) h 8h 6] ! ) 6+ % J8 6o > #- !

> a )

r 8h 6] ! % ) 6(n V nx o ! ' w ! '

o L ' v M

o '! lCL

o @'# M i1- % h M #* • ' ! |! # - ) 6" t $j

9.5.2 Các b c th c hi n chuy>n 5i m t tablespace gi a database

E t > h s ' 6] " ! #J > % ) Z " # * ! % "

&' #- !' !

!' ! Z " G Z ) 9* ! " ! 6(n ^ F ) 6h 8h 6] " G > Z ) O B b " ! 8h

i[ # # '& &' #- !' ! ! (* j E 8h 6] !

(86)

e( ! 9J' ^ F ) i! )v j

s ) #!' 6h 6( " ! 9J' 6+ m t k h’ kqlrfk r

eh ! SALES_1 9JSALES_2 > Z " # ' ) > % )• s

= x

EXECUTE dbms_tts.transport_set_check('sales_1,sales_2', TRUE); E= J8 % 9J ( ' ) Y > JxTRANSPORT_SET_VIOLATIONS ^ F )

= 9O 6h M # % x

SELECT * FROM transport_set_violations;

: 9O % M O % V ) ' ! % ) Z " # * ! )'J

&' !' !

< " 6] & ) " b ! 9I & ) " v' 6h % ) ' ! |! !

9J' ! J8• H ' ' 6] !

ALTER TABLESPACE sales_1 READ ONLY;

.^ F ) ) F + CM!' b 6h % M O " ! J8x

EXP TRANSPORT_TABLESPACE=y TABLESPACES=(sales_1,sales_2) TRIGGERS=y/n CONSTRAINTS=y/n GRANTS=y/n FILE=expdat.dmp TRIGGERS=YN ' ! |! % M O •NN % ) ' ! |! % M O

GRANTS=YN % M O " 58I #V ) - ! 6>•NN % ) % M O

CONSTRANTS=Y N " J ) - # ƒ 6(n % M O •N N % ) % M O " J ) -#

s ' |! " G b ! 9S 6(n % M O #- + % " ef & & ) " (R ) ' ! 9S 6(n M # M|

ALTER TABLESPACE sales_1 READ WRITE;

; e( ' b " G 9S 6(n ' |! 9J' + ( ) Z ) 9* 6+ ? E' 9J' #* 9* #Z 58I u.@Q0

D e( " ! 6o 6(n % M O 9J' #*

IMP TRANSPORT_TABLESPACE=y

DATAFILES=('c:\db\sales_jan','c:\db\sales_feb', )

TABLESPACES=(sales_1,sales_2) TTS_OWNERS=(dcranney,jfee)

FROMUSER=(dcranney,jfee) TOUSER=(smith,williams) FILE=expdat.dmp

9.6.T%O TABLESPACE

9.6.1 L nh t o tablespace

> h ^ F ) = : 6h &' #- ! EB ! "!x

CREATE TABLESPACE tablespace

DATAFILE filespec [autoextend_clause] [, filespec [autoextend_clause]] [MINIMUM EXTENT integer[K|M]]

(87)

[ONLINE|OFFLINE] storage_clause:= =

STORAGE ( [INITIAL integer[K|M]] [NEXT integer[K|M]] [MINEXTENTS integer]

[MAXEXTENTS {integer|UNLIMITED}] [PCTINCREASE integer]

) r* x

tablespace tên c a tablespace c t o

DATAFILE tên data files c a tablespace c t o DEFAULT STORAGE

tham s l u tr m c nh cho t t c i t ng c t o l p tablespace

MINIMUM EXTENT

kích th c t i thi u c a extent c s d ng value

ONLINE t ch s d ng (Online) cho tablespace t t o l p

OFFLINE t ch ch a s d ng (Offline) cho tablespace t t o l p

PERMANENT tablespace có th s d ng l u tr i t ng th ng trú

TEMPORARY tablespace ch s d ng l u tr i t ng trung gian (temporary objects) Ví d : s d ng l u tr d li u s"p x p theo câu l nh ORDER BY r+ Fx

CREATE TABLESPACE app_data

DATAFILE ‘/DISK4/app01.dbf’ SIZE 100M, ‘/DISK5/app02.dbf’ SIZE 100M

MINIMUM EXTENT 500K

DEFAULT STORAGE (INITIAL 500K NEXT 500K MAXEXTENTS 500 PCTINCREASE 0);

E„ ) ( ) s• > h s ' ) C ! ) N C1x E &8 ' ) )

E y ! š™E

' ) / ! ) b ) - + • ! 9J' ! c y 0@@ ' ) ) - + E @ G • t " G

; ' ) ! P CM ! ) • ! 9J' " ) ( ) ? E y #F E

m •

.$ (n ) $ " ! #V J ? $ (n ) $ " G ' ) #V ! J K

9.6.2 Ch qu n lý tablespaces

r* = &' ! ) (R ) ( • ƒ &' ! 9*

(88)

eh s k ! ' ! ( ) ! "! :' 8v1 ) ! P 6( 4# 9J' = # 6IxMANAGEMENT LOCAL AUTOLOCATE

r+ Fx

CREATE TABLESPACE lmtbsb DATAFILE

'c:\data\lmtbsb01.dbf' SIZE 50M

EXTENT MANAGEMENT LOCAL AUTOALLOCATE;

9.6.3 T o temporary tablespace

9 > h &' #- #!' ! ^ F ) ' _! M ! " % ) a ) 6h ( (R ) B "

eh &' #!' ! • > h ^ F ) : ) $ ) ( &' ! ) (R )• ( ) > 4# S % '"TEMPORARY $

r+ Fx

CREATE TABLESPACE sort

DATAFILE ‘/DISK2/sort01.dbf’ SIZE 50M MINIMUM EXTENT 1M

DEFAULT STORAGE (INITIAL 2M NEXT 2M MAXEXTENTS 500 PCTINCREASE 0)

TEMPORARY;

r* C ! ) • J# ' " (* x E &8 ' ) )

E y ! š™E

' ) / ! ) • ! 9J' ( ) Z ) c y 0@@ 6h h #F E @ G ' ) E @ G t S ) G F h

; E y C1< l0lu ' ) ># y ' ' ? QO# B E

9.6.4 Các tham s l u tr

:(n ) % ) ) a ) ' #- ! 6(n M" ' ) # 6I ( i ' ) j E" # $ J8 6(n M" ) & R h# &' ! ' ) (R ) n! % ) t …

" # $ J8 ' ) &' ! iCREATEj• " # $ ƒ 6(n ^ F ) " ) " ' #f

E> #- $ # $ ( P =# x

INITIAL58 %+ (* b M 6P 7+ (* p O b M 6P

4 J K ' % ˜ i2*DB_BLOCK_SIZEj 1f • %+ (* J8 J ; ' % ˜ i5* DB_BLOCK_SIZEj

NEXTZ ) 9* %+ (* b M Z 7+ (* $ h J K ' % 1f • %+ (* J8 J ; ' % ˜i5* DB_BLOCK_SIZEj

MINEXTENTS $ (n ) M 6(n &' ! #V % )# 6(n &' ! 1f ) " J8 J

PCTINCREASE ! P {# { ) %+ (* M 7+ (* b #- M 6(n M" ' %+ (* x

(89)

r+ FxNEXT = 200K, PCTINCREASE = 50 + 6(n M Z ˜ KK7• M ( ˜ KK7• M Z ( ˜ ;K7

MAXEXTENTSM" $ (n ) $ " M > ' ) #- )# / " p O J / " * O ' #f ! F - 9J' %+ (* b ' %

/ " J8 „ ) > h 6(n M" ) ) " UNLIMITED• ( ) 6( ) 9* ) " J2147483645

9.7.CÁC THAY EI I V I TABLESPACE

9.7.1 Chuy>n 5i m t tablespace thành m t temporary tablespace

> h 6] " ! ) c & 6h > J #- #!' ! r+ Fx

ALTER TABLESPACE tbsa TEMPORARY;

9.7.2 Thêm m i tablespace

eh # - ) % ) ) b ! > h s ' " x 4# #* " G 9J' !

8 6] ) (n ) " G

T'f „ ) > h ^ F ) = : ! ( x ALTER TABLESPACE tablespace

ADD DATAFILE filespec [autoextend_clause] [, filespec [autoextend_clause]]

r* C ! ) • J# ' " (* x E &8 ' ) )

E y ! š™E

' ) / ! ) • ! 9J' ( ) Z ) c y 0@@ 6h h #F E @ G ' ) E @ G t S ) G F h

9.7.3 M r ng data files

> h s # - ) i 6] j %+ (* G ' " x - ) ' 6- s 6- ) ^ F ) S % '"xAUTOEXTENTED

1 - ) ' 6- ! s ! i# 8j ^ F ) ALTER TABLESPACE, ALTER DATABASE

$ • l‰f • h€ '8$&(J$( $ x m •lr EB ! "!x

ALTER TABLESPACE tablespace

ADD DATAFILE filespec [autoextend_clause] [, filespec [autoextend_clause]]

r+ Fx

ALTER TABLESPACE app_data ADD DATAFILE

‘/DISK6/app04.dbf’ SIZE 200M AUTOEXTEND ON NEXT 10M

MAXSIZE 500M; ' ) C1 s " (* x

(90)

E 8h * B ! E y ! š™0 @ G

' ) / ! ) ! 9J' " ) b G

; ' ) ' M ! ) ! 9J' " ) ( ) Z ) ? QO# B E

$ • l‰f • h€ '8$&(J$( $ x }k k •lrh¢ • m EB ! "!x

ALTER DATABASE [database]

DATAFILE 'filename'[, 'filename'] autoextend_clause

' ) C1 s " (* x E &8 ' ) )

E 8h * B ! '

E y G

' ) ! P ' M ! ) • O# 9J' B C ' CM ; QO# B 0!!

9.7.4 Thay 5i kích th c data file

8 93 # - ) %+ (* b \ ) " 4# 9J' " G • „ ) > h # - ) \ ) " I t { ) %+ (* b G

.^ F ) = : 6h 6] %+ (* b G ALTER DATABASE [database]

DATAFILE 'filename'[, 'filename'] RESIZE integer[K|M]

r* x

integer Kích th c t i c a file data file

.^ F ) = : 6h 6] ( #f x ALTER TABLESPACE tablespace

{MINIMUM EXTENT integer[K|M] |DEFAULT storage_clause }

r+ Fx

ALTER TABLESPACE app_data MINIMUM EXTENT 2M; ALTER TABLESPACE app_data

DEFAULT STORAGE (INITIAL 2M NEXT 2M MAXEXTENTS 999);

9.7.5 Chuy>n 5i ch ONLINE OFFLINE

W t > h M O 9J' ! > ) & ) " ' ' ) #- 9J (R ) n!• > h 6] & ) " J 'GG 9* #F 6+ x

@ 8h " G * + % "

(91)

eh 8h 6] 6-ONLINE9JOFFLINE• > h s = : x ALTER TABLESPACE tablespace

{ONLINE

|OFFLINE [NORMAL|TEMPORARY|IMMEDIATE] }

• h€ &EE ! (

9 % ) ' ! |! s = : 6$ 9* " 6$ (n ) > ' ) ! 6o 6(n OFFLINE

9 s %!' 6$ 9* O " G - ! (* % 8h

) 6-OFFLINE

1V % 6(n # • > h 8h 6- 'GG ' O " ! )'& S u C1 9J " ! ( ) Z ) 9* " ' % )# #!' )#

' ) C1 > h s ' " (* x E &8 ' ) )

E 8h * B !

E y ! ( ) Z )

' ) / ! ) • 6f 6- ' ) GG ' ' ; QO# B 0!!

9.7.6 Di chuy>n data file

† - % h ! • > h 8h " G ' " ! ( ) Z % " t ' $(% $'B (2,' (

: J8 t "! F ) ' " ! % ) ! J u C1 ! • 9J % ) Z ' % )# #!' )#

E= x

ALTER TABESPACE tablespace

RENAME DATAFILE 'filename'[, 'filename'] TO 'filename'[, 'filename']

r+ Fx

ALTER TABLESPACE app_data RENAME DATAFILE ‘/DISK4/app01.dbf’ TO ‘/DISK5/app01.dbf’;

s ' " (* x

E 8h 6- 'GG ' !

@ 8h " G ( ) Z ) \ ) b I J s ALTER TABLESPACE RENAME DATAFILE E 8h & 6- ' ' ! 6>

; ^ F ) b I J 6h M'" G „ P t ' $(% '$'B'2(

: J8 t "! F ) ' " ! % ) J u C1 9J % ) Z ' % )# #!' )#

E= x

(92)

RENAME FILE 'filename'[, 'filename'] TO 'filename'[, 'filename']

r+ Fx

ALTER DATABASE RENAME FILE ‘/DISK1/system01.dbf’ TO ‘/DISK2/system01.dbf’; s ' " (* x

'Y

@ 8h G \ ) b I J

1' &

s ALTER DATABASE RENAME FILE ; &

$ &( k l | z k E &8 ' ) )

E 8h * B ! c y G ( ) Z )

' ) ! P / ! ) • 6] & " ) + n! QO# B 0!!

9.7.7 Tablespace chD c

.^ F ) : 6h ! " 6- J8 EB ! "!x

ALTER TABLESPACE tablespace READ{ONLY|WRITE}

r+ Fx

ALTER TABLESPACE app_data READ ONLY; $ &( k s t r qz• k œ

E &8 ' ) )

E 8h * B !

E y !

E y ! š™1 % l

; QO# B

$ • l‰f • h€ ˜ h£ kqlrfk r

> h ! 6- t 6y ' ! % > # ' #- $ I % x ! ! ) '

7 ) > ' J' M 6$ 9* ! 6> ! % ) Z " ' % )#

T R % ) > ' % ! !

9.7.8 Hu- tablespace

' ) #- 9J (R ) n! > h U ! % p

r J8 > h s = : x

DROP TABLESPACE tablespace

(93)

tablespace tên c a tablespace c hu$ INCLUDING CONTENTS

hu$ ln segment có tablespace CASCADE CONSTRAINTS

Hu$ c ràng bu c liên quan t i b ng

bên ngồi có t # O * " ) - !

U r+ Fx DROP TABLESPACE app_data

INCLUDING CONTENTS; $ &( k s t r qz• k

E &8 ' ) )

E 8h * B ! y ! ( ) Z )

E y ! š™l #'9 QO# B

9.8.THÔNG TIN V2 CÁC TABLESPACES

1- $ Y ) )

$ k| ‘ ™ •

DBA_TABLESPACES, USER

TABLESPACES @ A ) b " !

DBA_SEGMENTS, USER_SEGMENTS

2 ) 9I )# > ' ) " ! DBA_EXTENTS,

USER_EXTENTS ) 9I M > ' ) " !

DBA_FREE_SPACE,

USER_FREE_SPACE ) 9I G M > ' ) " !

V$DATAFILE ) 9I O " G • ' )c# $ !

9J !

V$TEMPFILE ) 9I " #!G • ' )c# $ ! 9J

!

DBA_DATA_FILES T h " G - " !

DBA_TEMP_FILES T h " #!G - " #!' !

V$TEMP_EXTENT_MAP ) b " M ' ) " ' # ) #!'

!

V$TEMP_EXTENT_POOL ) b " ' # ) #!' ! '

)c#x & ) " b #!' ! i9a ) % ) ) # ) ) j 6(n ^ F ) #V

V$TEMP_SPACE_HEADER T h 9a ) % ) ) wG b #V #!G

DBA_USERS E" ! #f 9J #!' ! b "

DBA_TS_QUOTAS T& #Z ^ F ) ! b "

V$SORT SEGMENT ) 9I ' )# 6$ 9* #V

V$SORT_USER ) % ) ) _! M ! ) ) 6(n ^ F ) 9J

(94)

9.8.1 Xem thông tin tablespace

eh M # ) 9I ! • > h O8 ' ) ' Y r Y

DBA_TABLESPACES ( " ) J8 1- $ ) =#x

$ k| ‘ ™ •

TABLESPACE_NAME !

NEXT_EXTENT 7+ (* b " M # - ) + '

MAX_EXTENTS $ (n ) $ " M ' ) #- )#

PCT_INCREASE < P {# { ) ( ) %+ (* b " M

MIN_EXTENTS $ (n ) $ h " M ' ) #- )#

STATUS & ) " b ! J GG

CONTENTS < = '& ! J ! # #!'

r+ Fx

SVRMGR> SELECT tablespace_name, initial_extent, next_extent, > max_extents, pct_increase, min_extlen

3 > FROM dba_tablespaces;

TABLESPACE_NAME INITIAL_EX NEXT_EXT MIN_EXTENT MAX_EXTENT PCT_I MIN_EXTLEN - - - - - - -

SYSTEM 1240 10240 121 50

RBS 10240 10240 121 50

TEMP 262144 262144 999 50 131072

DATA01 204800 204800 999 50 51200

4 rows selected

SVRMGR> SELECT tablespace_name, contents,status 2> FROM dba_tablespaces;

TABLESPACE_NAME CONTENTS STATUS - - -

SYSTEM PERMANENT ONLINE

RBS PERMANENT ONLINE

TEMP TEMPORARY ONLINE

DATA01 PERMANENT ONLINE

4 rows selected

9.8.2 Xem thông tin data files

eh M # ) 9I G • > h O8 ' ) ' Y r YDBA_DATA_FILES ( " ) J8

1- $ ) =#x

$ k| ‘ ™ •

FILE_NAME G i > %•# 6(R ) € j ( ) Z ) 9* G

TABLESPACE_NAME b ! Z ) 9* G 6>

BYTES @ ) (n ) + ' b ! R

AUTOEXTENSIBLE E 6- s 6- ) # - ) ) (n ) b G

MAXBYTES @ ) (n ) $

(95)

r+ Fx

SVRMGR> SELECT file_name, tablespace_name, bytes, 2> autoextensible, maxbytes, increment_by

3> FROM dba_data_files;

FILE_NAME TABLESPACE_NAME BYTES AUT MAXBYTES INCREMENT_BY - - - - - /DISK1/system01.dbf SYSTEM 31457280 NO 0

/DISK2/rbs01.dbf RBS 5242880 NO 0

/DISK3/temp01.dbf TEMP 5242880 NO 0

/DISK4/data01.dbf DATA01 5242880 NO 0

(96)

Ch ng 10 C=U TRÚC L&U TR"

10.1.CÁC LO%I SEGMENTS

)# J " 9a ) % ) ) b " ' ‡ i6$ (n )j ' ) @(* 6=8• ƒ M # M| #- $ '& )# F h

10.1.1 Table

i )j• J ( ) ' ) @ ' ) #- 6(n ( ) % )

' #- Z s _ - E" ' ) #- - '& ' ! ' i% ) ! = % j ƒ ! ( ) ' ) a ) #- !

T3 9ƒ ? E" '& )# T3 9ƒ D E" '& )# i ! 'j

10.1.2 Table partition

E> h > #- $ ' ) > $ (n ) ! * 9J 6c ) R 6>• ' ) 6> ƒ 6(n ( J I ! ' i! = % j• #V ! ' > h \# " ! % " V n ! = J8 \ ) " ) " % '" #- 6(n ! = % • #V ! ' 6> 6(n M # ( #- )#

10.1.3 Cluster

E" ~ ) ' ) #- 6(n ( ' " ) " b (R ) % '" i% ' # j 1-> h Z #- I 9J > 6(n M # J #- % h 6'& i 8! 'G )# j E" ' ) #- - 9I a ) #- 6'& 9J > ) " + O (

10.1.4 Index

O " 6P #F i j Z ) 9* #- M F h 6(n ( ' ) #- M )# 1-> * ' M • ƒ > O8 M )# 6(n ^ F ) 1F 6+ b )# J8 J 3# % # 9J " ~ ) ' ) #- s #- % '" 6(n t

10.1.5 Index-Organized Table

' ) #- Mv' ) z • " ' ) #- M 6(n ( s 9J' ) " % '" 1- Mv' ) z % ) P #- a ) 6h 3# % # i ''% !j• " >

h 6(n 9I ) s ! S =8 M i M j

10.1.6 Index Partition

1- M > h 6(n ! ' i! = % j 9J - ) I ! % " 6>• #V ! ' b #- M ƒ ( ) Z ) 9* )# i6'& j 9J % ) 6(n ! |! \# J

4 I ! 1F 6+ + b ^ F ) M ! ' J 6h ) # h )

(97)

10.1.7 Rollback Segment

l' % )# 6(n ^ F ) ' ) ' i) ' j 6h &' " 6] ' )

(* % 6] " " M ' % • " ) " „ ƒ 6(n ( ) 9J' ' % )# r J# J8 ' ! |! > h ! F c & " 6]

10.1.8 Temporary Segment

7 #- s " ( CREATE INDEX• SELECT DISTINCT• 9J SELECT GROUP BY• ƒ $ )_ ) s ) _! M ! ) ' ) - * ) _! M ! P I % ) ) • " % J8 ƒ 6(n ) s ! 6g #!' )# ƒ 6(n a ) ' ) (R ) n! J8

10.1.9 LOB Segment

7 #- I - ' ) ( ) " 6$ (n ) * i ) ' ‡ v : Q j ( " 9{ J • • ' E" - Z * J8 ƒ 6(n ( ) ' ) "

)# ) 6(n ( J : Q )# ƒ t ( ) " ) " a ) 6h • M" ( ) " : Q ( ) Z )

10.1.10 LOB Index

1- : Q M )# 6(n &' )P# #V % : Q )# 6(n &' ! E" + O ( ) b : Q M > h 6(n 58 1F 6+ b ^ F ) : Q

M )# J ' ! |! 3# % # " ) " F h ' ) - '& : Q

T3 9ƒ E" '& )# i ! 'j

10.1.11 Nested Table

E- ' ) > h 6(n &' ! S #- v G i ) ' )(R a ) ) g j ' ) (R ) n! J8• ) ( ) Z ) 9* ! P ^ - - i j•

6(n ( #- 9J 6(n ( ) ' ) #- )# )

10.1.12 Bootstrap Segment

Q'' ! )# • 6(n ( #- )# • 6(n &' G ! 5 #V % 6(n &' )# ) B! ' % &' ' #V %

6(n # #- @ ' ) '' ! )# % ) h M # ^ • !

6(n „ ) % ) P ! =# * )# J8

10.2.QU N LÝ EXTENTS

10.2.1 C p phát thu h9i extents

r O! ! " " M M #V % )# 6(n &' #* • 6(n # - ) 8 6]

(98)

rJ > ƒ c % )# U• 6] • _ * i j l ) 6$ 9* " ' % )# • " M > h s 6- ) c

10.2.2 S6 d ng gi i phóng extent

7 #- ! 6(n &'• " G - ! ƒ Z " ! P ) x T ' %• ( ) Z ) 9* ' % 6P b G

< P ~ & b G J " ! P ~ $ )

T3 9ƒ d ^ F ) 9J ) ! > ) " M

1V % )# 6(n &' !• > ƒ 6(n O! ! " #- 9a ) % ) + n! S ) M ~ $ ) ' ) ! )# ƒ $ )_ ) ^ F ) I O " 9a ) % ) ) !

% O! ! " • M 6> ƒ 6(n M # J M i M 6o 6(n ^ F )j " )# ) ! > ) 9a ) % ) ) • " M ( ) Z ) 9* > ƒ 6(n ) ! > ) 9J 6( 9J' 9a ) G M i M V j b ! r* O! ! " 9J ) ! > ) " M >

h )=8 (n ) ! = 6'& 9a ) ' ) " G b !

10.2.3 K t h?p vùng không gian tr ng

> h s % n! " 9a ) % ) ) $ ) ! #V % " M ' ) a ) #- ! 6(n ) ! > ) e I J8 O A M • 9+ Fx % > U i '!! j E" M $ ) J8 > h 6(n % n! & J #- M ' ) " I % x

7 SMON% &' #- ! ' 6h % n! " M $ )

7 P ! O! ! " 9a ) $ ) #J > P * (n ) % ) ) $ ) * % ) ) b #- M

7 n! ' 84 P b

T3 9ƒ K n! " 9a ) % ) ) $ )

z ‡

(99)

G ¡ x• ›f ˆ ‘

r Y DBA_FREE_SPACE_COALESCED 6(n a ) 6h M # ! J' > " M V ) > h % n! 6(n 9* ^ F ) = 9O 6=8 6h O8 " ) x

SVRMGR> SELECT tablespace_name, total_extents, 2> percent_extents_coalesced

3> FROM dba_free_space_coalesced

4> WHERE percent_extents_coalesced <> 100; TABLESPACE_NAME TOTAL_EXTE PERCENT_EX - - -

RBS 33

DATA01 22

2 rows selected

s % n! " 9a ) % ) ) $ ) ' ) ! \ ) (* 6=8x ALTER TABLESPACE tablespace COALESCE;

$ &( Qk s t r qz• k

.^ F ) ) F ! )

E 8h * B CM! ! E y ! ( ) Z )

E y #F '' š™E' L CM

10.3.BLOCK D" LI#U

10.3.1 C u trúc c8a block d li u

T3 9ƒ EO B b Q ' %

E" Q ' % b 6(n O J S " ! P x

Q ' % i9a ) 6P jx T Z t b ' % • ) 9I ' 8• 'Y ' 8• 9J " ' ' ) ' ) Q ' % ƒ { ) P '

(* ) S M $ ) (*

@ ! i9a ) jx E" ~ ) 6(n &! 9J' ' % ' (* ) S (* L ! i9a ) $ )jx ) $ ) ' ) ' % J 9a ) \# ) 9a ) 9J 9a ) % ) ) ( ~ ) Q 6P • 9a ) % ) ) $ ) J ! 9* #- R ) ^ F )• 9a ) % ) ) $ ) ' ) #- ' % > h ! = 6'& ' M'" 9J ! • 6] " ~ ) eh ) 58 9O 6I J8•

9 ' ! |! s % n! " ! = 6'&

10.3.2 Các tham s s6 d ng không gian block

(100)

k| ‘ h w x y

T3 9ƒ E" # $ ^ F ) % ) ) ' ) ' %

E" # $ INITRANS9J MAXTRANS t $ (n ) % &'• $ (n ) * O " ' ' • 6(n &' ' ) #V M ' % ' % E" ' ' 6(n ^ F ) 6h ( ) " ) 9I " ' J# 6] " ' % & a ) #- R h# 1V ' t ^ F ) #- ' '

INITRANS6(n )" ) " #f \ ) ' )# • 9J ' M )#

MAXTRANS 6(n )" ) " #f J ;;• a ) 6h &' )(, ) 6$ 9* " ' 6c ) R > J# 6] " ' % M ' % ! ) " J8• 9a ) % ) ) ' " ' ' ƒ 6(n # ' 6h > h s " ' #- "

$ k| ‘ h w x y ˆ lz { }{ l t

PCTFREE ' ) #- )# t (n ) ! P {# 9a ) $ ) ' ) #V ' % 6h J

' { ) b ' ! " ~ ) ' ) ' % ' #f • PCTFREE J K ! P {#

PCTUSED ' ) #- )# t (n ) ! P {# $ h b 9a ) % ) ) ^ F )•

' 6> ( ) " ' % b 1- ' % ƒ 6(n &! & 9J' G i " $ )j #V % PCTUSED) # M $ ) L b #- )# J " " ' %

` a ) ' O! ! " #V % > ~ ) 6(n ' #f #V G ƒ 6(n &' ( ) Z ) 9* #V )# # $ FREELISTSM" $ (n ) G 1f • PCTUSED \ ) K ! P {#

PCTFREE 9J PCTUSED 6(n + '" ' ! P {# 9a ) % ) ) b • Z J 9a ) % ) ) b Q ' % ~ & S 9a ) % ) )

10.3.3 S6 d ng không gian block

eh F h• ' … " (* ^ F ) " 9a ) % ) ) ' ) ' % 6$ 9* #- > PCTFREE=209JPCTUSED=40x

(101)

T3 9ƒ ^ F ) 9a ) % ) ) ' ) ' %

, k r x K› % ) ) ~ & ^ F ) ' { ) %+ (* b " ~ ) ' ! & " ~ ) J8

, k r5x M'" ~ ) ' ) ' %• 9a ) % ) ) $ ) ' ) ' % ƒ { ) • B J8 9€ ( h 9J' ' % 6(n

, k r1x 9a ) $ ) ' ) ' % 6& * #Z PCTUSED• & > h 9J' Q ' % & _ 6P S (* K

10.3.4 Phân lo i m3c phân o n i v i t,ng lo i segment

$kqlrfk r , “ l m Œ }„ u h€ f “ h m

.u C1 @ ' ) M

: 0!! ' lO +

@0 @ )# œ

X@C[ M )# œ

lQ l' % )# X I

C1< #!' )# lO I •

7k • > ) g J t 6B ) 9* " ! - '& PERMANENT

T (n ) ! = 6'& M 9* #Z 6- % " 6$ 9* " '& )# % "

% "' ( I ! % " 6h ) # h ^ F ) o ) ! + " 9a ) % ) )

, “ l m &q•r f “ h m

E" '& ' ‡ % " 6(n %4 (* 6=8 ' #Z 6- { ) P 9I ! = 6'& x

E" ' ' ‡ • )'& S " i ) % h# j• 6I % ) ' ) R '!! r3 B ) % ) ! = 6'& ' ) !

ra ) % ) ) ^ F ) ' ( " Z ) F ) 6(n O! ! " 9J c ' ) 5" " O B & - * r3 • " ( J8 > #Z 6- ! = 6'& J O!

@ )# 9J M ) # 6(n ^ F ) ' ( )(R a )

-" Z ) F ) E-" 6$ (n ) J8 (R ) > #Z 6- ! = 6'& '

@' " ' % )# 6(n ! = ] & M #- " s 6- )• B ) A )=8 (n ) ! = 6'& ' ) $ )

#!' )# ' ) " ! # ! (R ) M 84 6(n M (n ) ! = 6'&

10.4.THÔNG TIN V2 C=U TRÚC L&U TR"

10.4.1 Các view l u tr thông tin

2 ) 9I " ! • G • )# • 9J M i ) 9I ! P ^ F ) P ! P ~ $ )j 6I > h O8 S " S h

2 ) 9I ! > h 6(n ( ' ) DBA_TABLESPACES ) 9I " G

(102)

T3 9ƒ E" Y Z ) 9I O B (

10.4.2 Xem thông tin v* segments

2 ) 6(n ( ' )DBA_SEGMENTS

T3 9ƒ ; < = '& " ) + > ' ) @Q0m.C/1CX

> h O8 ) 9I " )# ' " '& x

2 ) ] ) n!x W • )# • '& )# • ! ) 9I %+ ,x M • ' %

2 ) ( x INITIAL_EXTENT, NEXT_EXTENT, MIN_EXTENT, MAX_EXTENT, PCT_INCREASE

r+ Fx [ # $ (n ) " M 9J ' % 6(n O! ! " ' S ) )# ' SCOTT SVRMGR> SELECT segment_name,tablespace_name,extents,blocks 2> FROM dba_segments

3> WHERE owner='SCOTT';

SEGMENT_NAME TABLESPACE_NAME EXTENTS BLOCKS - - - -

EMP DATA01 55

DEPT DATA01

BONUS DATA01

SALGRADE DATA01

DUMMY DATA01

5 rows selected

10.4.3 Thông tin v* extents

(103)

T3 9ƒ ? < = '& " ) + > ' ) @Q0mC[ CX

> h O8 ) 9I " M ' " '& x

2 ) & )x W • )# • #o M

2 ) 9I %+ , 9J 6f x TABLESPACE_NAME, RELATIVE_FNO, FILE_ID, BLOCK_ID, BLOCKS

r+ Fx [ # ) 9I " M > ' ) #- )# ' (* SVRMGR> SELECT extent_id,file_id,block_id,blocks 2> FROM dba_extents

3> WHERE owner='SCOTT' 4> AND segment_name='EMP';

EXTENT_ID FILE_ID BLOCK_ID BLOCKS - - - -

0

1 27

2 32 10

3 42 15

4 57 20

5 rows selected

10.4.4 Thông tin v* vùng tr ng

2 ) 9I " 9a ) $ ) 6(n ( ' )DBA_FREE_SPACE

T3 9ƒ D < = '& " ) + > ' ) @Q0mLlCCm.<0EC

r Y J8 Z " ) 9I

r+ Fx SVRMGR> SELECT tablespace_name, count(*), 2> max(blocks), sum(blocks)

3> FROM dba_free_space

4> GROUP BY tablespace_name;

TABLESPACE_NAME COUNT(*) MAX(BLOCKS SUM(BLOCKS - - - -

DATA01 1284 1533

RBS 2329 2419

SORT 1023 1023

SYSTEM 5626 5626

TEMP 2431 2431

(104)

Ch ng 11 QU N LÝ ROLLBACK SEGMENTS

11.1.GI I THI#U ROLLBACK SEGMENTS

11.1.1 Khái ni m

1V % > s 6] ' ) • " „ 6I 6(n ( & 6h > h % ! F & & ) " b (* % 6] l' % )# 6(n a ) 6h ( " ) " „ 6> l' % )# ( ) " ) 9I ' % ( ' % @• 9J " 6o ^ 6] b

' %

T3 9ƒ l' % )#

< P 6P i j b #- ' % )# Z #- ' J ( ) ) 9I

" ) ' R > ^ F ) * ' % )# ) M # M| 1V ' t > h ^ F ) O #- ' % )# 6h ( ) " a ) 6h % ! F

X I ' > h 6c ) R ) ' % )#

11.1.2 M c ích s6 d ng segment

$ k k llqk x

7 #- ' s " 6] 6$ 9* " ~ ) ' ) • " ) " 6P i' # ) j ƒ 6(n ( ) 9J' ' % )# ' 6> 6(n ' % i O8 & j• " „ ( ' ) ' % )# ƒ 6(n O8 9J 6•4 & ' ) ' %• ! F c & " ) " ) 84 U

T3 9ƒ d 1F 6+ b ' % )#

, „ • $ k k

' ) (R ) n! #- )f! V % " ' ) s • P ! % ! F & " ( '## l' % ' ) (R ) n! J8 6(n )y J ! F c

r J8 t s 6(n % " 6] 6$ 9* " ' % )# 6o 6(n % n! ' " ' ') G

(105)

7 #- s " ' • " ' ) ƒ % ) h O8 6(n " 6o 6] #J ( 6(n '## ' E" „ ( ' ) ' % )# ƒ 9€ 6(n ^ F ) 6h ) O! ' " % " \# # ' O 5" ' " 6>

11.1.3 Phân lo i rollback segment

2G2$( % llqk x2r |r

.u C1 ' % )# 6(n &' ) ' ) u C1 ! #V % #- 6(n &' ! l' % )# J8 t 6(n ^ F ) 6$ 9* " 6] b " 6$ (n ) \#

' ) u C1 !

Y2G2$( % llqk x2r |r

1- > h > I ! 9J > + O #- ' v.u C1 ' % )# E" ' v.u C1 ' % )# ' &' ! > h 6(n ^ F ) 6h ( ) " 6] " 6$ (n ) > ' ) " ' v.u C1 ! % " E> '& ' v.u C1 ' % )#

< x < ' % )# J " )# 6(n ^ F ) ) ' #V

< x < ' % )# J #- ! P b ' % )# > ' ) < ' % )# > h 6(n ^ F ) <

11.2.SB D NG ROLLBACK SEGMENT

11.2.1 S6 d ng rollback segment transaction

nf f % llqk x2r |r

e$ 9* " ' ! M^ k #- % $ (n ) * " • P )" ' J8 9* #- ' % )# ) 84 J# # 9F ( ) " & ) " 6P b

E B k )" ' % )# ' #- ' x

:(R ) (* % $ (n ) ) ' ) ' P ' % ! a n! iG j 9* %+ (* b 9a ) $ ) i M j R b ' % )#

EO! ! " 9S 6b " 9a ) $ ) 9J % ) P O! ! " ] " 9a ) $ ) i M j ' ' % )# 6o 6(n )" ' ' 93 I J8 > h € ) #

O s b $ )

eh )" #- ' ' #- ' % )# #- " (R ) # ' % )# 6> P ! ) & ) " ' EP s SET TRANSACTION USE ROLLBACK SEGMENT (* % s " ' ) ' 6> X & ) " b ' % )# J 'GG 'f = SET TRANSACTION USE ROLLBACK SEGMENT % ) 6(n 6f + 6P

4 b ' $ ) ƒ ! " #- V

r+ Fx ^ F ) )" ' % )# ' ' & R h# _ 6P ' x

SET TRANSACTION USE ROLLBACK SEGMENT large_rs1;

% ' 6(n '## • ' % )# J8 & 6(n 6( 9I & ) " ` J ) ^ F ) ƒ s 6- ) )" ' ! ' ' #- ' % )# O %† J' ) ~ V i j S ! ' J8 & 6(n ! F )" ' ' % )# \ )

2Œ }„ rŠr

E" ' ^ F ) M ' ) ' % )# ' #- s M' 9~ ) ' 6>• ' ƒ ) 6] 9J' M R • c ! F 8h * " M % ! M $ a ) 6(n ^ F ) 6P8• > & 9I M

(106)

E> ' a ) ^ F ) #- ' % )# > K M

T3 9ƒ ;K ^ F ) ' ) ' % )#

& R h# _ 6P • ) ' _ 6P ) 9J' CM

' ) % s • " ' ƒ ) 9J' CM ' * % 6P8 c ! F

8h ) ) CM

7 CM „ ) 6P8• > ! F & & ) 9J' M M J8 & ) " V 'f 1- M J V 'f R > % ) ^ F ) O %† #- ' J'

11.2.2 T ng tr ng i v i rollback segments

l' % )# > ' p 6h M" M ) J# M J# 6P8• ' p ƒ

8h ) M % ! 6h s ) EZ ( ' M $ a ) c

& 9I M 6P M J8 ) V • > I % { ) M 6P J8 „ ) ) % ) V 6>• ' p % ) h " #J p M 6h 8h ) M 6(n eh ! F '& 6- ) ' ' • P ! ] ) 4# #-M 9J' M $ a ) r J8 &' s { ) ( ) 6$ 9* " ' %

)# r { ) ( ) 6$ 9* " ' % )# ƒ ! F M ' * % $ (n ) " M { ) % % ) 58 ' ) # $MAXEXTENTS

T3 9ƒ ; { ) %+ (* l' % )#

% ' % )# 6o 6(n &' !• 9€ > h 6] # $ ( b ' % )# eh 6] • t P I t " # $OPTIMAL MAXEXTENTS ' ! a n!

r+ Fx E= 6] $ (n ) $ " M O! ! " ' ' % )# RBS_01 ALTER ROLLBACK SEGMENT rbs_01

STORAGE (MAXEXTENTS 120);

r* = 6] J8• „ ) > h I t 9* ' % )# u C1 • ' )]# # $OPTIMAL

(107)

7 % B 'f '## " ' • > ƒ ) ! > ) 9a ) % ) ) 6o ^ F ) 6h ( " a ) 6h ! F c E" M ' ) ' % 6(n 6( & & ) " eh % # % ) ) ( ' ) ' % )# • > h $ ( & ' % )# 6> )

# $OPTIMAL

T3 9ƒ ; / # %+ (* b l' % )#

9 ƒ c & " M 6o O! ! " % x

7+ (* b ' % )# & 6(n I t * ) " b # $OPTIMAL > I K M V ! &

1- I ( k J % c & " M • ƒ c M Z = O (* 6>

> h s ) # * %+ (* b ' % )# ) ^ F ) =

ALTER ROLLBACK SEGMENT :( k• % J8 ' % )# 6(n p O ! )

& ) " '

r+ Fx p %+ (* ' % )# RBS1 \ )100Kx

ALTER ROLLBACK SEGMENT rbs1 SHRINK TO 100K;

E= ! + s B * %+ (* b ' % )# * %+ (* ( 6o 6(n t • B )y ƒ S ) & % > #- M % ) h c ' O %† ) 84 = J'

11.3.QU N LÝ ROLLBACK SEGMENTS

11.3.1 S6 d ng rollback segment

.… z• pk llqk x r |r

7+ (* b ' % 6(n M" † - 9J' $ x :'& ' 6(n s i • ! • • j :(n ) 6(n M^ k

2 ) (R )• 4# #* ) 9J' ) P + % ) ) ( ) ) ! F c J M'" % p ) r* ' " 4# #* • t P ( ) l q @ 9J' ' %• ' ) %

' " & P ! ( ) 'J - ~ )

e" ) " %+ (* b ' % )# { Z ' ' J O > ^ F ) ' % )#

2‘ lz› (Šr

r* " ' % )# > 5" I " M ƒ )=8 o ) ! + % ) ) ( • 6h ) # * o ) ! +• > h I t # $MINEXTENTS ' ! a n!

(108)

11.3.2 T o rollback segment

> h &' ' % )# ) = :x EB ! "!x

CREATE [PUBLIC] ROLLBACK SEGMENT rollback_segment [TABLESPACE tablespace]

[STORAGE ([INITIAL integer[K|M]] [NEXT integer[K|M]]

[MINEXTENTS integer]

[MAXEXTENTS {integer|UNLIMITED}] [OPTIMAL {integer[K|M]|NULL}] )

] :( kx

1- ' % )# > h J PUBLIC 'f PRIVATE i#f j )" J8 6(n s ) B &' 9J % ) h 6] J8

MINEXTENTS>=2 6$ 9* " ' % )#

PCTINCREASE6(n p 6$ 9* " ' % )# 9J 6(n )" \ ) K

OPTIMAL• > t % ) 6(n p ) " %+ (* % &' b ' % )# 6(n M" ' ) # $MINEXTENTS

INITIAL=NEXT6h # ' " M ' ) ' % )# > a ) #- %+ (* ) )" ) " 'MAXEXTENTS JUNLIMITIED93 ( ƒ € # - )

" M #- " % ) P

X4 6f ' % )# ' ) #- ! ) 6h ) # * (n ) ! = 6'& ' )

r+ Fx

CREATE ROLLBACK SEGMENT rbs01 TABLESPACE rbs

STORAGE (

INITIAL 100K NEXT 100K OPTIMAL 4M MINEXTENTS 20 MAXEXTENTS 100);

' ) C ! s ' " (* x

E &8 ' ) ) E y l' %š™E

' ) ! P / ! ) • ! 9J' • ! • 9J % h ( ) Z ) E y #F ' ) ' '

' ) ! P CM • ! 9J' " ) 9I ' % )# ; QO# B E

11.3.3 Thay 5i tr ng thái c8a Rollback segments

l' % )# > h #- ' ) & ) " ONLINE/OFFLINE

7 ' % )# > & ) " ' > ` J ) ^ F ) ' " ' • )(n & • & ) " 'GG ' > % ) ` J ) ' " ' ) (R )• ' %

)# J ' 9J ` a ) ' " '

' ) #- $ $ ) O • P 6f & ) " ' 'G 6$ 9* " ' % )# x

(109)

6 ) ^ F ) " ' % )# - ! 6> eh M^ k 6(n $ ) J8• P 6] & ) " b ' % )# J 'GG 6h ){ % ) ' ^ F ) " ' % )# (* % 6] & ) " b ! J 'GG

7 # $ '! i Uj " ' % )# • ( ) % ) h s 6(n ' 9€ ~ ' ) ^ F ) > eh M^ k 6(n $ ) J8• P ){ % ) ' ^ F ) ' % )# ) 6f & & ) " ' % )# J 'GG

% &' #* #- ' % )# • > ƒ > & ) " 'GG 9J ( h ^ F ) ) 6(n eh > h ` a ) ' " ' • ' % )# P 6(n 8h & ) " J '

2 ) = ALTER ROLLBACK SEGMENT EB ! "!x

ALTER ROLLBACK SEGMENT rollback_segment ONLINE | OFFLINE l' % )# ƒ > & ) " ' ' * % _ i 'Y j ~ m l r llqk x r |r k x k f }k kqk r

eh # ' ' " ' % )# & ) " ' ) % % 6- ) i !j • P t … b ' % )# ' ) # $ ROLLBACK_SEGMENTS b

! # G

r+ Fx

ROLLBACK_SEGMENTS=(rbs01, rbs02, rbs03)

z ‡x $ (n ) $ " ' % )# ' 6$ 9* #- 6(n M" # $ MAX_ROLLBACK_SEGMENT

$ &( k š y s t r qz• k x E &8 ' ) )

E 8h * B l' % )# E y ' % )# ( ) Z ) E y l' %š™< w % GG ; ' ) -! '& M" • O# B u

11.3.4 Instance s6 d ng rollback segment

eh F h• M # M| " (* s % #- ^ F ) ' % )#

^ F ) O " ' % )# > ' ) ! P # $ ROLLBACK_SEGMENTS

# $TRANSACTIONS 9JTRANSACTIONS_PER_ROLLBACK_SEGMENT 6(n ^ F ) 6h + '" $ (n ) ' % )# P ' #- x

r* x

N S l ng rollback segment c n thi t T Giá tr tham s TRANSACTIONS

TRP Giá tr tham s

TRANSACTIONS_PER_ROLLBACK_SEGMENT

' ) (R ) n! X p \ ) $ (n ) ' v.u C1 ' % )# > 6(n • „ ) ƒ % ) P * I ' % )#

(110)

11.3.5 i*u chDnh kh n ng l u tr c8a rollback segment

> h I t " + O ( b S ) ' % )# ) ALTER ROLLBACK SEGMENT

EB ! "!x

ALTER ROLLBACK SEGMENT rollback_segment [STORAGE ( [NEXT integer[K|M]]

[MINEXTENTS integer]

[MAXEXTENTS {integer|UNLIMITED}] [OPTIMAL {integer[K|M]|NULL}]

) ]

$ &( k s t r qz• k x E &8 ' ) )

E 8h * B l' % )# E y ' % )# ( ) Z )

' ) ! P CM ! ) • 6f & " # $ ( ) Z ) ; QO# B 0!!

11.3.6 Gi m b t r ng c8a rollback segment

' ) (R ) n! # $ OPTIMAL 6(n t …• ƒ > )_ ) s O! ! " 9J ) ! > ) 9a ) % ) ) s ' ) " b # $ OPTIMAL X)(n & • > h s

O! ! " % ) ) ) s !x

ALTER ROLLBACK SEGMENT rollback_segment SHRINK [ TO integer [ K|M ]];

' ) (R ) n! # $ ) % ) 6(n t …• ƒ ) # (n ) % ) ) ' % )# 9I * ) " OPTIMAL

$ &( k š y s t r qz• k x E &8 ' ) )

E 8h * B l' % )# E y ' % )# ( ) Z ) E y l' %š™ %

; ' ) -! '& % l' % )# • y ! # z B )y %+ (* ' % )# ' %+ (* 6o 6(n $ ( T'f y z c ! 9J' ) " %+ (* ' 9a ) % ) ) ( ) Z )

? QO# B

11.3.7 H8y b@ rollback segment

' ) #- $ (R ) n! % ) P ^ F ) " ' % )# • > h b8 " ' % )# ) = :x

DROP ROLLBACK SEGMENT rollback_segment; $ &( Qk l | r qz• k x

E y ' ) ) E 8h * B l' % )# E y ' % )# ( ) Z )

(111)

11.3.8 Qu n lý undo t ng

7 { ) k ' s 6- ) i0 '# W ' ) # v 0W1j J #- 6f h# % " #* b d E ) O! ' @Q0% &'• 6] %+ (* 9J I t ' % )# ' ) ' 6>• l' % )# > h 6(n &'• M'" I t %+ (* #- " s 6- )

@ ' % 6(n k R 9J' ' !

r+ Fx &' ' !

CREATE UNDO TABLESPACE 

UNDO_TBS

DATAFILE 

/u01/oradata/freeney9/undo_tbs01.ora

SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE 700M

1- $ # $ % &' + x

UNDO_MANAGEMENT (MANUAL / AUTO)x E ' > ^ F ) 0W1 % ) @ G ˜10XW0:

UNDO_TABLESPACE (valid tablespace)x E t … ' ! ^ F ) UNDO_RETENTION (in seconds default=30)x E ' R ) A 6h s

'## '

UNDO_SUPPRESS_ERRORS (TRUE / FALSE)x E ' $ ) > 9I M ! ' % ) % •.C l0X.0E X W.C l ::Q0E7 C/1CX ž! " V @ G ˜ lWC

11.4.THÔNG TIN V2 CÁC ROLLBACK SEGMENT

2 ) 9I " ' % )# 6(n ( ) ' ) S h

11.4.1 Xem thông tin chung v* rollback segment

2 ) ) 9I ' % )# 6(n ( ' ) Y DBA_ROLLBACK_SEGS

T3 9ƒ ; E" ) + 9I ' % )#

E" ) ' )c#x

SEGMENT_IDx 1o b )# SEGMENT_NAMEx )#

TABLESPACE_NAMEx ! Z )#

OWNER (PUBLIC/SYS): )#

STATUS (ONLINE/OFFLINE): & ) " b )# r+ Fx [ # ) ) 9I )#

(112)

SEGMENT_NAME TABLESPACE_NAME OWNER STATUS

- - - -

SYSTEM SYSTEM SYS ONLINE

RBS1 RBS SYS ONLINE

RBS2 RBS SYS ONLINE

RBS3 RBS SYS OFFLINE

4 rows selected

@ ' ) - OWNER " ) " x SYSx l' % 6> - '& ! PUBLICx l' % 6> - '& !

11.4.2 Xem thông tin th ng kê v* rollback segment

O8 6(n " ) J8 S " YV$ROLLSTAT9JV$ROLLNAME

T3 9ƒ ; E" ) $ ) %4 9I )#

r+ Fx [ # " ) ) %4 9I )#

SVRMGR> SELECT n.name, s.extents, s.rssize, s.optsize, 2> s.hwmsize, s.xacts, s.status

3> FROM v$rollname n, v$rollstat s 4> WHERE n.usn = s.usn;

NAME EXTENTS RSSIZE OPTSIZE HWMSIZE XACTS STATUS - - - - - - -

SYSTEM 43 2199552 2199552 ONLINE

RBS1 20 202752 204800 417792 ONLINE

RBS2 38912 38912 PENDING

OFFLINE

3 rows selected

@ A ) #- $ - ' ) Y V$ROLLSTAT

$ € ™ •

USN :J $ b ' % )# il' % )# # j

EXTENTS $ (n ) " M > ' ) ' % )#

RSSIZE 7+ (* b )# R + '

XACTS $ (n ) " ' ^ F ) ' % )#

OTPSIZE / " OPTIMAL b ' % )#

HWMSIZE T ) Y # %•%+ (* $ + ' • % ' % )#

{ )

AVEACTIVE 7+ (* b M R •

(113)

11.4.3 Thông tin v* rollback segment ang active

> h % n! ) ' ) )V$TRANSACTION9JV$SESSION

T3 9ƒ ;; ) 9I " ' " " )#

r+ Fx

SVRMGR> SELECT s.username, t.xidusn, t.ubafil, 2> t.ubablk, t.used_ublk

3> FROM v$session s, v$transaction t 4> WHERE s.saddr = t.ses_addr;

USERNAME XIDUSN UBAFIL UBABLK USED_UBLK - - - - -

SYSTEM 2

SCOTT 163

2 rows selected @ A ) # $

-$ € ™ •

SES_ADDR e t b ' • O8 6(n SV$SESION.SADDR

XIDUSN $ b l' % )# 6(n ^ F ) '

UBAFIL, UBABLK,

UBASQN,UBAREC

r + R b ' % )# #J ' ƒ ) 9J'

USED_UBLK $ ' % ' 6(n &' '

START_UEXT, START_UBAFIL, START_UBABLK

.$ b M iG • ' %j - ' % )# #J

' _ 6P )

11.5.CÁC V=N 2 LIÊN QUAN T I ROLLBACK SEGMENT

11.5.1 Thi u không gian cho transactions

@' #- ' % ) 6(n ^ F ) I ' % )# > h M & ) 9a ) % ) ) ' " ' % )# 9J )=8 V iORA-01562j X) 84 = > h J

#-' ) " (R ) n! x

(114)

.$ ( ) " M ' ) ' % )# 6o 6& * ) " MAXEXTENTS 9J % ) h ] ) 4# " M 9J' ' % )# iORA-01628j

• f f

r* V ORA-01560x

1 - ) 4# " G ' ) ! ef 6- ' " G JAUTOEXTEND Q] ) #* G 9J' !

r* V ORA-01628x

{ ) # $MAXEXTENTS b ' % )#

T U 9J &' & ' % )# 9* %+ (* b M *

11.5.2 L.i c d li u không 9ng nh t

9 $ )_ ) # ' " = ƒ t M^ k " 6o 6(n '## r3 • " ( '## ƒ % ) 6(n ^ F ) ' ) (R ) n! % ) &' 6(n " ( ) " „ " i v ' # ) 'G j• ƒ 6(n V ORA-01555 snapshot too old :V J8 M % ' 6] " 6o 6(n '## 9Jx

' ' > ' ) ! P ' % ) 6(n ^ F )

/ " 6P i G' v # ) j ' ) ' % )# 6(n ) 6• #- ' % "

• f f

{ ) t $MINEXTENTS - ) %+ (* M

{ ) ) " OPTIMAL

11.5.3 Ch:n session

T3 9ƒ ;? E f '

3n hw

7 #- M ' ) ' % )# 6(n ) 6P8• ƒ ! F ^ F ) M % ! ' M' 9~ ) ' ) (R ) n! M % ! 9€ ) ' ) & ) •

' ƒ % ) ^ F ) 6(n > 1f % " • > „ ) % ) h p M % ! 6h 8h * M > V 6>• ' % )# ƒ 6(n ] ) 4# " M r J# J8 J# ' ' % )# )J8 #- # - ) 9J P ! ! 6h

(115)

9 P s % h# ) b " ' ) 6(n s ) O8 ) S " Y V$ROLLSTAT• V$TRANSACTION• V$SESSION 6h ! "

" ' ) • S 6> s I t ' ! a n! E2 ) % h# 9J ) "# " J8 6(n s \ ) )(R

r+ Fx [ # ) 9I " ' ) 6(n s

SVRMGR> SELECT s.sid, s.serial#, t.start_time, t.xidusn, s.username

2> FROM v$session s, v$transaction t, v$rollstat r 3> WHERE s.saddr = t.ses_addr

4> AND t.xidusn = r.usn

5> AND ((r.curext = t.start_uext-1) OR

(116)

Ch ng 12 QU N LÝ TEMPORARY SEGMENTS

12.1.TEMPORARY SEGMENTS

#!' )# 6(n ^ F ) % s " = _! M ! #J % ) h ^ F ) 9a ) % ) ) ' ) - * ' % ) 6b• 9+ F (x

SELECT ORDER BY CREATE INDEX

SELECT DISTINCT SELECT GROUP BY SELECT UNION

@ ) (n ) - * P ' _! M ! 6(n M" s # $ % &' SORT_AREA_SIZE ' ) #- $ (R ) n!• I ' " _! M ! a ) 6(n ^ F ) 9J P

I - * J8 - * ' ) b #"8 J % ) h 6"! Z ) 6(n 9J % b _! M ! 6> P ! 6(n &# R ( 6g ) 6g ( " ) ) J8 + J

#!' )#

#!' )# ' ) ! 6(n &' ! 9* #F 6+ ^ F ) J# 9a ) * ) ) V n ' " _! M !

T3 9ƒ ;D #!' )#

12.1.1 Phân lo i temporary segments

E" #!' )# > h 6(n &' #- ! # ! 'f #- #!' ! W > h ^ F ) #- ' ) " % h ! J8 6h _! M !

(117)

$r|f k $kqlrfk r

1- #!' ! 6(n ^ ' " #!' )# ( ) Z ) 9J % ) Z O %† )# J' > % h % " > h &' " #!' ! ' = : x

CREATE TABLESPACE tablespace_name TEMPORARY DATAFILE filespec [autoextend_clause] [ , filespec [autoextend_clause]]

1- ! # ! > h 8h 6] J & ) #!' ! \ ) " ^ F )

= x

ALTER TABLESPACE tablespace_name TEMPORARY

:( kx 9* = 4 • ! % ) 6(n ! |! Z O %† #- 6$ (n ) (R ) B J' i (x • ' ! ' • j 1- #!' ! > h 8h 6] & J ! #

! ) = : (* 6=8x

ALTER TABLESPACE tablespace_name PERMANENT

9 > h &' #- #!' )# ' ) #- ! # ! 9* $ I % x

W s = _! M ! P 9a ) % ) ) 6g

W &8 = #J > 6o 6(n )" ' #- ! # ! 6h s _! M ! #- ! # ! 6(n ^ F ) ' _! M !• #- > h > #- 'f

I #!' )# ' ) !

1- #!' )# ƒ 6(n b8 I X % % B = _! M ! 9J 9a ) % ) ) 6o O! ! " ƒ 6(n ) ! > ) 6h ' " 6$ (n ) % " b ^ F ) < # ! 6(n ^ F ) ' _! M !• > 9a ) % ) ) ' ) ! >

h 6(n ! = 9a ) % " ) (R )• #V ! 6(n ^ F ) ' S ) _! M ! % "

7 #- #!' ! 6(n ^ F ) ' " #!' )# • t &' #-)# a ) 6h _! M ! ' ! 1- 9J ' P _! M ! ] 6g > h ^ F ) a ) )# • #- M % ) h a ) ‚ 6c ) R ' I

' % "

12.1.2 S6 d ng Sort Segments

.' )# 6(n &' = _! M ! 6P ^ F ) * #!' ! ' _! M ! rJ ' )# t b8 % _ i 'Y j r J8 J# ) # * $ P O! ! " 9J c " ' )# ! F 9F ' ) _! M !• J# { ) { ) O $ )

% ) & $ (n ) " M O! ! " ' #V ' )# - #- #!' !

12.1.3 Sort Extent Pool

9 ( & ' )# ' ) 9a ) ' CM <'' b 9a ) * /0• #V = P * " 9a ) $ ) 6h s _! M ! > h 3# " M V ' ) 9a ) * J8

12.2.C=P PHÁT KHÔNG GIAN CHO TEMPORARY SEGMENT

#!' ! 6(n ^ F ) 6h { ) _! M ! 7+ (* b " M ' ) #!' )# 6(n M" DEFAULT STORAGE b ! ( ) Z ) @' (n ) ) #!' )# \ ) ! P ) 84 P ) " SORT_AREA_SIZE @' 8• 6f INITIAL = NEXT = (n*SORT_AREA_SIZE)+ DB_BLOCK_SIZE

(118)

12.3.THÔNG TIN V2 CÁC TEMPORARY SEGMENT

T3 9ƒ ;d ) 9I

> h O8 6(n " ) 9I #!' )# ' ) #- $ ) S h x DBA_SEGMENTSx Z ) 9I O " '& )# ' )

V$SORT_SEGMENTx ' & ) " b " ' M !'' i9a ) % ) ) _! M !j r* S h J8• > h 6(n ) ) x

$ € ™ •

TABLESPACE_NAME #!' !

EXTENT_SIZE 7+ (* b M

TOTAL_EXTENTS ] ) $ " M TOTAL_BLOCKS ] ) $ " ' %

USED_EXTENTS $ (n ) M 6o ^ F ) USED_BLOCKS $ (n ) ' % 6o ^ F )

FREE_EXTENTS $ (n ) M ~ $ )

FREE_BLOCKS $ (n ) ' % ~ $ )

MAX_SORT_SIZE 7+ (* $ b 9a ) _! M !

MAX_SORT_BLOCKS $ (n ) ' % $ a ) 6h _! M ! r+ Fx

SVRMGR> SELECT tablespace_name, extent_size, 2> total_extents, max_sort_blocks

3> FROM v$sort_segment;

TABLESPACE_NAME EXTENT_SIZ TOTAL_EXTE MAX_SORT_B - - - -

TEMP 128 128

1 row selected

MAX_SORT_SIZE 9J MAX_SORT_BLOCKS J $ (n ) " M 9J " ' % ^ F ) ! |! _! M ! * O ) J8 J + ' ) I t %+ (* b #!'

!

V$SORT_USAGEx ' ) 9I " _! M ! > b • % n! 9* V$SESSION 6h 4# " ) x

r+ Fx

(119)

3> FROM v$session s,v$sort_usage u 4> WHERE s.saddr=u.session_addr;

USERNAME USER TABLESPACE CONTENTS EXTENTS BLOCKS - - - - - -

SYSTEM SYS TEMP TEMPORARY 128

(120)

Ch ng 13 CLUSTERS VÀ INDEX-ORGANIZED TABLES

13.1.TENG QUAN V2 CLUSTERS VÀ INDEX-ORGANIZED TABLES

' ) #- ) ) (R ) )(R ^ F ) > O I ) * & 9I I % h ! = " " J ) ' ) ) #- ) 6(n &' P 6P > ) " J ) 6(n • 9J' ' ) 6'& _ 6P b ' % 6P ' ) M 6P X ( ) #- % " = @1: 6o 6( #- 9J $ ( s b " ' % ' ) " " ' % s '• " J ) # ) ' ƒ

J# ' " = J8 O % > ' ) {! M ! " J ) ' ) )

T3 9ƒ ?K :( " ~ ) ' )

#-E V n #- 9J 5" I % h " J ) 6(n ( #- 6(n ^ F )• ƒ ( O " J ) #J > a ) ) " % '" ' ) a ) #- Q ' % > h ) Mv ) z 6(n ^ F )• )(R ^ F ) > h I % h s b " J ) @

' ) ) Mv' ) z ƒ ' ) s b % '" t

13.1.1 Cluster

1- a ) 6h Z ! " J ) > ' ) #- ' %

T3 9ƒ ? E

2s x k {k q• hz› l r q• x ƒ l r

(121)

X ) ORDER 9J ) ITEM 6(n ( ' ) #- B ) ƒ ‚ a ) #- ! = 6'& 1- ' % ' ) ! = 6'& J8 > h ( " J ) b ) X #- ) 6s ( ' ) #- • ƒ J 9 k ( 9J ) ƒ J s h ')

h~ … pk l r E" > 6f + x

1V ' ) R „ ) > % i% '" b j a ) 6h M" " J ) P ! ># & 9*

E % > h s #- - I

-E" ) ' ) #- ! > " - ( ) Z ) 9* %

E J ' ) $ 6$ 9* Z ) F ) ^ F ) " ) @ ' ) " ) 6(n > h 6(n ' " ) $ ) ( " ) ) (R )

E ! #- - ' ) % '" b > h € ! & + b J ) 6> E % 6- ! 9* ! # % i% '" + j b ) E" ) ' ) > h > ! # % < # % J8 > h # ) 9J' %

E 6(n a ) 6h V n { ) M O )€ ' ) > h • ( ) % ^ F ) 9O 'J ) " ) 6(n ƒ

#

E ƒ 58 ) " " # $ ( b O " ' ) 6>

13.1.2 Xem xét ch n l a Cluster

£ kqlr l r

.^ F ) " 6h ( #- I #J B ) (R ) M 84 6(n ^ F ) 6h 9O i+ s " ' " ! j 9J " J8 (R ) 6(n % n! 9* ! |! % $ ' ) = 9O

£ lsk € Œ }„ l r r

r y s " - ^ F ) ' % J % " y ) > I

-6(n ^ F ) ' ) " ! |! % $ ) I b = 9O • ^ F ) ' " 9* % J ># b O " - 6> ) (R )• 6f M ' ( ) Z ) 9* " - ' ) %

1- % $ J % #J ^ F ) > > h ! = 6I $ (n ) " 'Y i ~ )j #V ># " > % ( ) Z ) 9* I 'Y ' ) % & > ) % % " & > 5" + " 'Y

7 > 5" I 'Y ( ) Z ) 9* #- % ƒ J# ' 3# % # #- ~ ) J' 6> ' ) $ %|# 1f % " • 6f " E % 6$ 9* ) - > # I ) " + „ ) % ) r+ F ( 6f % 6$ 9* " - ) " ') • # I ) "

b - J8 t J 9J G ' % - J8 „ ) % ) ! "

6(n

13.1.3 Các ki>u cluster

(122)

T3 9ƒ ? E" % h E

! }rŠ l r

1- M ^ F ) #- M 6h ' ' ) #- • " M J8 6(n )y J Mx

E M ! > ` ' ( • M O 9J ' ' ) #- M

M 6(n ^ F ) 6h p #- ' % #J Z " J ) 9* #- ) " % '" EO B b M ( ) s ( #- ' # M• #f P ' # M % )

Z ) " % '"NULL• ( ) M > h Z ) " % '"NULL E t > #- h# 9J' i 8j ' #V % '" ' ) M• 93 B ) > h p ' 9* M )

(R ) ' ) a ) #- ! ) " % '"

eh ( 9J M O " J ) S • ' ^ F ) M 6h M" J ) 6P ( ) Z ) 9* ) " % '" 6> M O " J ) ' ) " % '"

X #- 9J J ) ' ) M > a ) ) " % '"• % '" % ) f! & ' #V J ) ' ) #- ) 9* $ * " J ) a ) ) " % '"• ^ F ) M > h J# ) # $ (n ) % ) ) 6g P (

k l r

T ^ F ) #- Z { ) + '" + b " J ) TJ# {# i j ^ F ) % '" 9J > h 6(n )(R ^ F ) ) g $ )

7 #- J ) 6(n • 9J' ' ) ) ' ) #- x E- % '" 6s ^ F ) 6h + ) " {# i j TJ ) 6(n ( s 9J' ) " {#

TJ# {# ^ F ) 6h M" " J ) ' ) % ' ) % M O S " ) 6(n

{#• T ' #- { ) * ' 9* M

13.1.4 Ch n l a ki>u cluster

:( ' ) J #- " \# J# { ) O b $ )• { ) (R ) $ 6- 9I " b = 9O ^ F ) J #- ' ) $ " " y s

) ' v > %•# ' M ( ) Z )• ^ F ) M 9J ^

F ) r* #- > ^ F ) M #- M • % ~ ) ' ) • ƒ ^ F ) " % i) " % '"j ' ) M 6h r* ^ F ) i > ^ F ) ! ( ) ! "! {#j• ƒ ( " 'Y b

' ) #- 9J ~ ) J8 ) #- G ' i J# {#j ^ F ) G ' 6h &' " ) " & ) $• )y J " i) " {#j E" 6(n M" s 9J' " ) " b " - / $ ) ( % '" b M

(123)

-eh M" 6(n #- ~ ) ' ) M + O P ! s K ' " 9J' 9* x

EP * + O J #- ' " 9J' 6h M" 6(n % ' ) M rJ P #- ' " 9J' 6h 6y 'f ) ~ ) ' )

" & • 9* ^ F ) G ' 6h M" " 'Y ' ) #- ƒ % ) P ! ^ F ) O Z #- ' " 9J' J' X ( J a ) " J8 > h ) # * 6(n

" ' " 9J' 6h 6y ) ~ ) ' )

#-2 z z› h y| pk f z– f f k ! }rŠ

E ! ( ) ! "! M ) 9J ) 6I > ) ( 9J (n h# ) @' 6>• P { Z 9J' ) (R ) n! F h ) 6h y s ! ( ) ! "! ^ F ) ' n! k

z› h y| pk f z– f f k }rŠ œ

E" = 9O ^ F ) # 6I ' " \ ) 6$ 9* % 8x SELECT WHERE cluster_key = .; ' ) ) (R ) n! J8 % ' ) " I % ' " \ ) ƒ 6(n "! F ) J# {#• ) " {# v % ( ) Z ) ƒ a ) 6h M" ~ ) ' ) ' ) % 6>• 9* M ) " % ƒ 6(n

3# ' ) M (* • 9J 6> #* 6y ~ ) s s ' )

E" ' ) (R ) > %+ (* + 6] ' > h M" $ (n ) " 'Y 9J #Z 6- % ) ) ^ F ) b " ' ) "

' ) #- 84 P 9a ) % ) ) I J 9a ) % ) ) O! ! " ' O s b $ ) ƒ ) # 6" ) %h ' 84 P 5" I e$ 9* " 9O " 9I I ~ ) % ) \ ) 9* % i6 I % 9O - '& ' " % ) \ )j r+ F• 'J - 6h O8

" ~ ) s 9J' ' " % i ' " % "! F ) " V j J8• G ' % ) h ^ F ) 6h 6( " % ) $ ) ( ' ) (R ) n! ' "

\ ) 6(n x SELECT WHERE cluster_key< ; r* M • " % 6(n _! M ! ' ) M• ' A J ) > h 6( " % ' #o # 6I ' " WHERE% ) ( ) 6( )• J# ) # * " ' " M O 9J' > %+ (* (R ) M 84 6(n { ) ( ) #J % ) ) * & 9a ) % ) ) J ' > ƒ % ) P ! M" ) S 6P r* ! ( ) ! "!

) ƒ )=8 % > % { 93 %+ (* b " ' ) R „ ) 6(n M" S 6P ' ) % ^ F ) M )• > h I t 6h { ) (n ) % ) ) J ' % P

7 " Z ) F ) (R ) M 84 s " ' " 'J - • ^ F ) ! ( ) ! "! {# ƒ )=8 $ %|# 93 ! F "! F ) J# J8

13.2.QU N LÝ CLUSTER

13.2.1 T o cluster

EB ! "!x &' E

CREATE CLUSTER [ schema ] cluster

(column dattype [, column datatype ] ) [ PCTFREE integer ]

[ PCTUSED integer ] [ INITRANS integer ] [ MAXTRANS integer ]

[ SIZE integer [ K | M ] ] [ storage-clause ]

(124)

r* x

schema owner c a b ng

column tên c a c t làm khoá cho cluster

cluster tên c a cluster

data type ki u d li u kích th c c a c t làm khố

SIZE ch nh khơng gian yêu c u b i toàn b hàng t #ng ng v i giá tr khố, #n v tính byte, kilobyte hay megabyte

INDEX Ch nh cluster t o m t index cluster z ‡œ

X %+ (* iSIZEj % ) 6(n ) g ) " #f ƒ 6(n ^ F )x ' % ^ F ) ) " J8 6h 6" ) " $ (n ) * O ) " % '" > h • 9J' ' ) #-' % b r+ F SIZE 6(n % &' ) " KK• ' ) % %+ (* b #- ' % J K • % ! P ~ & % ' ) dKK b ' % ' ! |! •

r3 #- ' % > h Z 6(n d) " % '" &' M E

CREATE INDEX [ schema ] index

ON CLUSTER [ schema ] cluster [ PCTFREE integer ]

[ INITRANS integer ] [ MAXTRANS integer ] [ TABLESPACE tablespace ] [ storage-clause ]

E- % '" % ) P ! t ' M 93 B ) 6o 6(n ) g % &' ef M ' ) " ! % " #J 6(n ^ F ) 6h &'

&' ' ) E

eh &' #- ) ' ) #- M s " (* x &'

&' M ' i Mj

&' )

E> h &' ) (* % &' M Q (* O s (* % • 9J' ' ) )

CREATE TABLE [schema.]table ( column_definition

[, column_definition ]

[, [CONSTRAINT constraint] out_of_line_constraint ] )

CLUSTER [schema.]cluster (column [, column ] ) 6ICLUSTER t \ ) ) ! 6(n 6f ' )

#-1- ) #J 6(n 6f ' ) #- % ) h > " - + k b ) > 93 )# % ) ! b ) > #J J #- ! P b

:( kx ! > M #* ' " 6(n ' ) \# ' ) r+ Fx

&' E

(125)

SIZE 200 TABLESPACE DATA01

STORAGE(INITIAL 5M NEXT 5M PCTINCREASE 0); &' M ' E

CREATE INDEX scott.ord_clu_idx ON CLUSTER scott.ord_clu TABLESPACE INDX01

STORAGE(INITIAL 1M NEXT 1M PCTINCREASE 0); &' ' ) E

CREATE TABLE scott.ord (ord_no NUMBER(3)

CONSTRAINT ord_pk PRIMARY KEY, ord_dt DATE, cust_cd VARCHAR2(3)) CLUSTER scott.ord_clu(ord_no); CREATE TABLE scott.item

(ord_no NUMBER(3) CONSTRAINT item_ord_fk REFERENCES scott.ord,

prod VARCHAR2(5), qty NUMBER(3),

CONSTRAINT item_pk PRIMARY KEY(ord_no,prod)) CLUSTER scott.ord_clu(ord_no);

13.2.2 T o Hash Cluster

eh &' #- 9J 6f ) 4 >• s " (* x &'

&' )

E= ' &' #- ( ) s ( = ' &' M EB ! "!x

CREATE CLUSTER [ schema ] cluster

(column datatype [, column datatype ] ) HASHKEYS integer

[ HASH IS expression ] [ PCTFREE integer ] [ PCTUSED integer ] [ INITRANS integer ] [ MAXTRANS integer ]

[ SIZE integer [ K | M ] ] [ storage-clause ]

[ TABLESPACE tablespace ] r+ Fx

&' E

CREATE CLUSTER scott.off_clu

(country VARCHAR2(2),postcode VARCHAR2(8)) SIZE 500 HASHKEYS 1000

TABLESPACE DATA01

STORAGE(INITIAL 5M NEXT 5M PCTINCREASE 0); &' " ' )

CREATE TABLE scott.office(

(126)

#-1 6I HASH IS > h 6(n ^ F ) 6h ) g #- J# {# i G ' j ' )(R ^ F )6 ) g

13.2.3 Xác nh giá tr SIZE cho cluster

SIZE a ) 6h ) g % ) ) ^ F ) O " J ) ' % '" e(n ^ F ) ' % h 6h 6" ) " x

.$ s 6& ) " % '" ' #- ' % ' ) M / " + M" $ ) " % '" ' ' % ' ) $ k| ‘ 2!Z(

# $ SIZE6 ) g % ) ) ^ F ) 'J - " J ) ' ) " % '" b r+ F 6$ 9* M #V 6f J ) > K #f J ) 9J %+ (* b #V J ) ' ) ) J K • #- J ) ' ) ) #f J ) > %+ (* J • # $ SIZE ƒ 6(n

+ ( x

7 58 %+ (* b SIZE ' T E y ) " * ) " + #-6h " % ) 6b % ) ) (

13.2.4 Các tham s chD nh cho hash cluster

E> # $ + 6(n t ' " J HASHKEYSx $ ) " % '"

HASH ISx † y ' J# {# ' )(R a ) ) g '2 (G2

S % '" HASHKEYS t $ ) " % '" a ) ' # $ J8 a ) 9* # $ SIZE 6(n ^ F ) 6h 6" ) " %+ (* 6P b ) ) 6(n ! ' ' ) 5" &' 6s M" ' ) Z x

r* x

E" M 6(n ! % ) g ' ) # 6I STORAGE ƒ ! F % ] ) %+ (* b " M 6o 6(n ! \ ) * ) " + '"

'2 !2

TJ# {# > h 6(n ) g • J# 6(n y P M # M| + ! = " b ) " % '" x

E> % { ) ! = " * O " J ) ' ) ' ) $ " ) " % '"

E$ )_ ) ) # h $ 6F ) 6- i ' ' j eF ) 6- ƒ M % #- 9J ) " % '" {# a ) #- % & ) 6F ) 6- M ƒ )=8 % ) 6b % ) ) Z = " J ) • #- ' p ƒ 6(n 6f 9J' ' ) ' %• #- ) #* 6(n 6f ' % #*

(127)

1- J# {# > h Z O %3 = : n! J'• " J# ' ) g % ) h # ) 9J' J# {#

13.2.5 S6a 5i Cluster

E" ^ 6] 6$ 9* E ' )c#

8 6] # $ ( 9J " # $ ^ F ) ' % 6] ) " b # $SIZE ' M

EO! ! " 9J O8 & % ) ) (

E" ) " HASH IS 9JHASHKEYS % ) h 6] 6(n \ ) = ALTER '

r+ Fx

ALTER CLUSTER scott.ord_clu

SIZE 300 STORAGE (NEXT 2M);

B• † hi k š y s t }rŠ k l r

t $ k ! }rŠ

l r lk r ALTER

CLUSTER 6] " # $ ^ F ) % $ E> E>

8 6] " - + ( i S INITIALj E> E>

EO! ! " 9a ) $ ) E> E>

c 9a ) % ) ) % ) ^ F ) E> E>

8 6] SIZE E> )

8 6] HASHKEYS9JHASH IS v )

TRUNCATE

CLUSTER /" ^ F ) % ) )! > ) % ) ) E>E> )7 ) E" = ALTER CLUSTER•TRUNCATE CLUSTER9JANALYZE CLUSTER > a ) #- B ! "!

( ) Z ) 9* = ' )

13.2.6 Xoá Cluster

1- t > h M'" ( O " ) 6o 6s M'" • I J8 > h s _ ) " ^ F ) # 6I † y INCLUDING TABLES ' ) = M'"CLUSTER

8 \ ) " M'" ) (* % M'"CLUSTER EB ! "!x

DROP CLUSTER [ schema ] cluster

[ INCLUDING TABLES [ CASCADE CONSTRAINTS ]]

1 6I CASCADE CONSTRAINTS ! 6(n ^ F ) O Z ) J' ' ) #

6 #- )' % '" iL' ) 8j b ) #J % ) - 9J' r+ Fx

.^ F ) # 6IINCLUDE TABLES 6h M'" " ) ' ) E DROP CLUSTER scott.ord_clu

INCLUDING TABLES; ['" " ) (* % M'" E

DROP TABLE scott.ord;

(128)

M T 6(n ^ F ) ' ) " (R ) n! % " ) (* 6=8 %4

ƒ ^ F ) M 9J x

Ÿ ! }rŠ k

< = " % '" 6c ) O iW G' # % ' j [ [ - ) s 6c ) 6I " ) " % '" i( r l f rk} xr kl rj [ E" % '" + 6(n ! i%k rl f}k r} xrj [ [

E" ) % $ v@ [

[" $ (n ) " ) " % '" [

E" 9O ^ F ) " % '" ( ) 6( ) [ $… n pk }{ l t

T 6'& 6=8 #2 ) + O b ' )

.s ! = " b ) " % '"x E" % " + n! ' ) $ ) + P s b ) " % '" J ( [ # s M^ + b 9+ F x " 6f J ) Z P

$ #f J ) ( % 6> > h > + X " 6f J ) > t #- #f J ) ' ) % 6> " 6f J ) % " > J ) {# #f J ) ' ) (R ) n! J8

^ F ) J % ) + n!

ra ) ) " % '"x / " % '" ! = " ' ) 9a ) ) " J % ) + n! ' % '" {#• 93 ( ƒ o ) ! + O I % ) ) ' ) #- 1f a '" {# 6o 6(n % H > h ) 58 9O 6I J8• O % > % % #- J# {# +

n! 6h ! " h

m h€ }{ l t q•

< ( ) Z 6( ( P 6(n M # M| ' ) % !

+ P s b ! " - % '"x " ) " % '" ' ) 6(n ! • J ) > h 8h + S ' % J8 ) ' % % " • I J8 > h J# ) # { ) r3 " - P 6(n ! (R ) M 84 % ) + n! # ) 9J' % '" b

+ P s b ‡' i% $ jx E" ) #J (R ) M 84 # ) 9J' % $ ' ) = ^ F ) )'& % '" J + ' ! Q 93 " J ) a ) J# ) " % '" 6(n ( a ) • ^ F ) > h J# ) # $ ' % P 6y ' #o #- 84 P J' 6> ' ) #- $ (R ) n! 6f ) i j

' ) J O > n • o8 M # M| (R ) n! ) 9I " = 6(n M O " ! ~ ) 9J 5| 'J - ) ! ~ ) J (R ) M 84 M ' )

(R ) n! J8 t a ) ) = ' )

e" ) " $ ) " % '"x ' ) • " J# {# s # $ t )(R a ) 9J' R h# &' B ) r 6" ) " ) " % '" %+ (* + M" J ! Z &! 93 " ) J8 6] 1- s y ' HASHKEYS9J SIZE > h € #- J# {# % ) 9J > h € o ) ! + % ) ) ( • 93

t ^ F ) % #J ) " b SIZE 9JHASHKEYS J > h 6" ) " 6(n (*

e I % 8x TJ# {# > h 6(n ^ F ) M O t % ) " % '" J 6(n r3 + ' J8 #J 3# % # ' ) #- % ' ) % ) h ^ F ) J# {# X = 9O ^ F ) s 9J' + ) ) \ ) ' ) % '" b B ) > h V n ' 5" {# > h &' #- M % '" b • I 9O ^ F ) 3# % # % ' ) ' ) - % '" b

(129)

2 ) 9I E 6(n O8 ' ) S h x DBA_CLUSTERS, DBA_TAB_COLUMNS, DBA_CLU_COLUMNS, DBA_CLUSTER_HASH_EXPRESSIONS

T3 9ƒ ? ) 9I E

13.3.1 Xác nh Cluster c t khoá Cluster

eh 3# b M - 9I SCOTT 9J " - J# % '" ' ) ^ F ) = x

SVRMGR> SELECT c.cluster_name, c.cluster_type, c.key_size, 2> cc.column_name, cc.data_type,

3> decode(cc.data_type, 'NUMBER', 4> decode(cc.data_precision,NULL,NULL, 5> cc.data_precision||','||cc.data_scale), 6> 'DATE', NULL, cc.data_length) AS "COLSIZE" 7> FROM dba_clusters c, dba_tab_columns cc 8> WHERE c.owner = cc.owner

9> AND c.cluster_name = cc.table_name 10> AND c owner= 'SCOTT';

CLUSTER_NAME CLUST KEY_SIZE COLUMN_NAME DATA_TYPE COLSIZE - - - - - - OFF_CLU HASH 500 COUNTRY VARCHAR2 OFF_CLU HASH 500 POSTCODE VARCHAR2

ORD_CLU INDEX 300 ORD_NO NUMBER 3,0

3 rows selected

13.3.2 L y thông tin c t khoá c8a cluster c t b ng

8 9O - DBA_CLU_COLUMNS 6h O8 ) 9I " " • " ) ' ) 9J " - x

SVRMGR> SELECT *

2> FROM dba_clu_columns 3> WHERE owner='SCOTT'

4> ORDER BY cluster_name, table_name;

OWNER CLUSTER_NAME CLU_COLUMN_NA TABLE_NAME TAB_COLUMN_NA - - - - - SCOTT OFF_CLU COUNTRY OFFICE COUNTRY

SCOTT OFF_CLU POSTCODE OFFICE POSTCODE

SCOTT ORD_CLU ORD_NO ITEM ORD_NO

SCOTT ORD_CLU ORD_NO ORD ORD_NO

4 rows selected

13.3.3 L y thông tin cho hash cluster

(130)

SVRMGR> SELECT c.cluster_name, c.hashkeys, c.function, 2> h.hash_expression

3> FROM dba_clusters c, dba_cluster_hash_expressions h 4> WHERE c.owner = h.owner(+)

5> AND c.cluster_name = h.cluster_name(+) 6> AND c.owner='SCOTT'

7> AND c.cluster_type='HASH';

CLUSTER_NAME HASHKEYS FUNCTION HASH_EXPRESSION - - - -

OFF_CLU 1009 DEFAULT2

1 row selected

13.4.INDEX-ORGANIZED TABLE

13.4.1 Tính ch t chung

T3 9ƒ ? Q ) 6(n ] Z ' % h M

n o lz {

1- Mv' ) z ( 'J - ' ) ' ) #- O B Qv lCC• Qv lCC M s % '" + b ) 9J > 6(n ] Z ) $ ) ( #- M E" ' % ! P " ' ) O B J8 Z " - % ) ! J % '" 93 " ROWID r3 9 ^ F ) Mv

' ) z P )# % " #- ' 9J #- ' M

$ Š n |€ }rŠY k ”r} kqlr

8 M O M 6$ 9* " ) ) (R ) 84 P #- I % $ ' % M 6(n 6y 6h M O ROWID9J 9J' ) s 9J' ) " b ROWID X)(n & 6y " )

Mv' ) z 84 P t " % $ M P 6(n 6y 93 'J - J ) > ` ' ) ! P J b '

1- Mv' ) z > h M O ^ F ) % '" + I - % n! # ) 9J' % '" + r 6] ) ( x 4# • M'" ! " J ) € %

! " M

2 {k }rŠY k ”r} kqlr kqlr

! }rŠY& k ”r} $kqlr $kqlr

7 '" M" O JROWID [" O % '" +

ROWID6(n )P# ^ F ) ' " M ) >ROWID

7 ) > " M ! F

FTS 9I " ~ ) % ) ' #- s @ O t $ 9J 9I " ~ ) ' Z s % '" +

E ' ! |! " J ) - O ) V n " J ) - O

TV n ! = 9a )• ! = " 9J 8I

(131)

1- Mv' ) z % " 9* ( x

ROWID > h J M" O ' #- J ) ' ) ) ) (R )• ' ) % J ) ' ) Mv' ) z 6(n M" % '" + b )

1- ) ) (R ) > h > I M E" M 6> ( ) " ROWID ( ) Z ) ' ) " % '" b M• ' ) % 6> 6$ 9* Mv' ) z % ) a ) ROWID

M Z O! ƒ % ) h &' % h ) J8 QO Z #- = : M O ) "

ROWID b ) Mv' ) z ƒ 6(n #- V

7 s 5| 'J ) ) ) (R ) s " J ) 9I J % ) h (* 6(n X)(n & 5" 9O 'J - ) Mv' ) z

" J ) 9I ' Z s b % '" + ' ) )

1- Mv' ) z V n O " '& ' )'& S '

1- Mv' ) z % ) # ) ' ) " ' i) ' ! =

" j• > % ) h ! = % i! ' j = i ! j

13.4.2 T o m t index-organized table

1- Mv' ) z ^ F ) ' ) (R ) n! x E" Z ) F ) c )

E" Z ) F ) % ) )

E" Z ) F ) M^ + ! = + s i :0<j

E" ) (R ) M 84 M O ^ F ) % '" + b ) EB ! "!x

CREATE TABLE [ schema ] table

(column-definition [, column-definition ]

[, out-of-line-constraint [, out-of-line-constraint ] ] ) ORGANIZATION INDEX

[ PCTFREE integer ] [ INITRANS integer ] [ MAXTRANS integer ] [ storage-clause ]

[ TABLESPACE tablespace ] [ PCTTHRESHOLD integer [ INCLUDING column ] ]

[ OVERFLOW segment_attributes_clause ] r* x

schema owner c a b ng

table tên c a b ng

ORGANIZATION INDEX

ch nh m t index-organized table

PCTTHRESHOLD ch nh không gian dành riêng index block cho hàng c a index-organized table ( n u hàng v t giá tr c# s ã c tính tốn , tồn b hàng c t ã c t tên m nh ! INCLUDING c chuy n vào phân o n overflow, n u phân o n overflow không c ch nh hàng v t giá tr PCTTHRESHOLD s+ b t ch i, giá tr m c nh c a 50 giá tr c a ph i n.m kho ng t 0-50

(132)

overflow, t t c c t ti p theo giá tr column c l u ph n phân o n overflow

OVERFLOW ch nh r.ng hàng d li u index-organized table v t giá tr ch nh c a PCTTHRESHOLD s+ c t phân o n nh ngh a b i segment_attributes_clause, m nh ! s+

nh ngh a tablespace, vùng l u tr t # $ 9I ^ F ) ' %

r+ Fx CREATE TABLE scott.sales ( office_cd NUMBER(3), qtr_end DATE,

revenue NUMBER(10,2), review VARCHAR2(1000), CONSTRAINT sales_pk

PRIMARY KEY(office_code, qtr_end)) ORGANIZATION INDEX TABLESPACE data01 PCTTHRESHOLD 20

OVERFLOW TABLESPACE data02; € ‘ • m

7 '" + ! t ' Mv' ) z • &' Mv' ) z ) #J % ) > % '" + ƒ V

X # $ PCTTHRESHOLD 6(n ) g 9J ! = 6'& '9 G 'Y % ) 6(n t " J ) 9(n 5" ) " PCTTRESHOLD ƒ S $ 9J ƒ #- V

13.4.3 Hi n t ?ng ROW OVERFLOW (tràn dòng d li u)

1- J ) * ' ) Mv' ) z > h ! " U 9a ) ( J8 6f b " J ) ' ) M• 9O 6I J8 > h % _ ! F 6(n \ ) " ^ F ) #- 9a ) '9 G 'Y

T3 9ƒ ?; J ~ )

1- J ) * ' ) #- Mv' ) z > h ! " U # 6- 9a ) ( b " J ) ' ) M rO 6I J8 > h ) 58 \ ) " ^ F ) 9a ) '9 G 'Y

$m f “ h m [ r |r \ |€ }rŠY k ”r} kqlr

7 #- Mv' ) z 6(n &' \ ) " t # 6I OVERFLOW " 9a ) 6=8 6(n &'x

1- ) • ') ž9* ) g ' ) # 6ICREATE TABLE6(n &' r3 'J -" J ) 6(n ( ' ) M• % ) > ! = 6'& #J ( ) Z ) 9* )

(133)

1- ) ! " J ) '9 G 'Y 6(n &' • b ) J8 J SYS_IOT_OVER_n• ' ) 6> J ) " P s b ' ‡ OBJECT_ID b Mv ' ) z

m h€ š y }rŠY k ”r} kqlr

1- Mv' ) z > h ^ F ) ) $ ) ( " ) ) (R )• O " = ) $ ) ( ALTER TABLE, ANALYZE TABLE, TRUNCATE TABLE 9J DROP TABLE9J O "

= @1: 6I > h s Mv' ) z

13.4.4 L y thông tin IOT (Index Orrganized Table)

2 ) 9I 6(n O8 ' ) S h T Y P =# J DBA_TABLES 9J DBA_INDEXES

T3 9ƒ ?? ) 9I

.^ F ) = 9O 6=8 %4 ) 9I " Mv' ) z 9J O B b B ) x

SVRMGR> SELECT t.table_name AS "IOT", o.table_name AS "Overflow",

2> i.index_name AS "Index",

3> o.tablespace_name AS "Overflow TS",

4> i.tablespace_name AS "Index TS", i.pct_threshold 5> FROM dba_tables t, dba_tables o, dba_indexes i 6> WHERE t.owner=o.owner

7> AND t.table_name = o.iot_name 8> AND t.owner = i.owner

9> AND t.table_name = i.table_name 10> AND t.owner= 'SCOTT';

(134)

Ch ng 14 QU N LÝ CÁC TABLES

14.1.TENG QUAN V2 TABLES

14.1.1 Phân lo i tables

E> #- $ ! ( ) ! "! ( )(R ^ F ) ' ) • > h 6(n ( ' ) ) 6$ (n ) x

l ) < '

Mm ) z E

%r lk $kqlr

l ) i (R ) 6(n )' J j J Z (R ) 6(n ^ F ) 6h (

e=8 J ) ) 6(n ^ F ) ' #f 9J J 6$ (n ) 6(n ! ) ) Z ' ) ( ) J8 > h I % h ) * & " ~ ) ! = " ' ) #- E" ~ ) > h ( ' #- s † - 9J' "

' " 6(n s ) 6> ,k r} $kqlr

1- ! ' i ) ! = % j ' ! |! M=8 s ) #- Z ) F ) ] < ' > #- $ 6f + x

1- ! ' > h > #- I ! ' • #V ! ' Z " ~ ) - 9J' #- o8 ) " b % i) " % '"j

1V ! ' ' ) #- ! ' )y J #- )# i! = 6'& j 9J > h 6f B ) ' ) " ! % "

< ' (R ) 6(n ^ F ) ' " > $ (n ) ) * ^ F ) " = 9O 9J > I ' " 6~ p ^ F ) 6c ) R I ! ' i j

E> h s 6> #- $ = 6f \# V n k 9J s " ' " ' ) " ! ' b ! '

T '& Mm ) z 9J E ƒ 6(n M # M| ' ) " ( ) ! '

14.1.2 C u trúc dòng d li u (row data)

E" ~ ) i 'Y j 6(n ( ' ) " ' % E" (R ) #V 'Y 6(n ( ' #- s ) $ ) ( s b " - i ' # j % ) g

E" (R ) > ) " XW:: ƒ % ) 6(n ( 1V 'Y ' ) > h > $ (n ) " (R ) % "

1V 'Y ' ) 6I >x

l'Y i! P ) 6P b ~ ) jx ( $ (n ) " (R ) ' ) ~ ) 6>• )'J ~ > ) 9I ) 9J ) 9I & ) " % '" b ~ ) 6>

(135)

-T3 9ƒ ?D EO B ~ )

E" 'Y 6(n ( I %I 9J % ) P O Z % ' ) " J' ) B ) 1V 'Y ' ) ' % 6I > " ) i ' j ' ) #F " 'Y @ #F " ) J8 p ! P 6P b #V 'Y

) O! #- 9J % h M=8 s ) ` a ) 6h ( " > % h 92 (* )• % h ! n! 9J % h

14.2.CÁC KI U D" LI#U TRONG TABLE

14.2.1 Ki>u d li u vụ h ng

Ôl t x s [ k k r\

@ %+ s > h ( ' % h V > 6- J % ) 6] iG M ) j 'f > 6- J 6] 6(n i9 ) j ' )

7 h %+ s > 6- J % ) 6] ( JCHAR• NCHAR6(n ( )_ 4# " % ' ) $ )

i % j NCHAR J % h X: i% h > V n 6f + )2 ) b S ) 5$ ) j

' ! |! ( " ! %+ s > 6- - ) % ) 6] > 6- - ) 6] iG M Y • Y j 7+ (* s 6& 6(n 58 $ a ) 6h ( %+ s• 9* #-) * & J KKK ' #- 'Y

7 h CHAR ! a n! 9* ( M= %k s - ) #o 0.E ' ) % % h

NCHAR ! a n! 9* ( M= %k s - ) #o ! Z &! • ) #o ' Œ )

& J8• #V %k s ( > h > %+ (* * #- ir+ Fx %k s ) $ • X Q • j

:( \ ) % h CHAR, NCHAR I % )=8 (n ) $ %|# - * #- " % ) P h H VARCHAR 9J NVARCHAR > h % _ ! F 6(n (n h#

J8 r* ^ F ) " % h VARCHAR9JNVARCHAR6h ( • - ) b ( + %+ (* % "' $ ) ƒ t O! 9S 6b - * 6h ( M= %k s #J

r+ F # '& ( M= ) " % h % "

{ l t Bã |Â y }{ l t z { }{ l t

CHAR(10) 10 bytes T e s t

? NCHAR(5) 10 bytes T e s t

VARCHAR(10) 4 bytes T e s t

? NVARCHAR(5) 8 bytes T e s t

(136)

J8 „ ) ( ) s ( VARRCHAR9J NVARCHAR• % h J8 6(n V n M^ k $ 9J ~ 6(n ! F V n ' ) " ! ! ' b % "' )(R ^ F ) a ) % h VARCHAR2 9J NVARCHAR2 ' % h " „ J VARCHAR9JNVARCHAR

7 h %+ s > 6- J 6] ƒ t ^ F ) #- $ P 6h ( ) " s s b - 9J > h 6] %+ (* ' #V J ) VARCHAR29JNVARCHAR2 J 9+ F b % h

%+ s > 6- J 6]

T3 9ƒ ? E" % h ' )

{ l t xy ‘ [ |r \

@ % h $ ' ) @ 6(n ( 9* % h > 6- J 6] E B ) > h ( 6(n ) ' $ * $

@ % h $ >x

1- 6h ( ! P #„

1- 6h ( ' $ ! P 1- 6h ( $ =#

y }{ l t [}k r\

9 ( % h ' ) #- (R ) > 6- J % ) 6] J D @ % h b ' ) R „ ) ' )c# R ) 6H8 6bx %U• {#• " )• )J8• ) R• ! B • ) =8 9J ! P {# b ) =8

y }{ l t ƒ [ kž\

7 h J8 ' ! |! ( " ! = p % ) s 8h

6] ! %+ s #V % % h Y 6(n 8h & ) " #"8 ' ) #& ) i% % h Y 6(n 8h S J8 ) % " ^ F ) ) F b j y }{ l t lz { h‘ z› l• [ &B\

& Q & %'N &B

1- - ' #- ) X I - ' #- )

7+ (* > h * /Q E> h * /Q

SELECT 9I SELECT 9I ' '

@ v i > h (

' ) #- ~ ) b j @6(n ' )> h J v) #J ! ' v'Gv( ) ' ) #-i % ) (! • > ^ F ) : Q ' ' 6h M" : Qj

7 ) V n ‡ 8! TV n % h ' ‡

(137)

X)'J • ) O! ?% h ' ( " 6$ (n ) * x CLOB9JLONG6h %+ s > 6- - ) % ) 6]

NCLOB6h ( %+ s X: > 6- - ) % ) 6] BLOB9JLONG RAW ' " ! O B

BFILE6h ( " ! O B ' ) I J

LONG 9J LONG RAW• (* 6=8• (R ) 6(n ^ F ) 6h ( ! O B ( # ) • ' # " ) k ‰ " ! )P 6=8• • % h J8 6(n \ ) % h LOB h LOB % " 9* LONG 9J LONG RAW ' B ) % ) h a ) € 9* LOB% ) V n ' " ( ) 9* LONG9J )(n & y }{ l t % ž!

l'Y @ J '" ^ ) > h 6(n ^ F ) ' ) = 9O a ) 9* " - > ' ) ) l'Y @ > #- $ 6f + x

l'Y @ J O ' #- 'Y ' ) l'Y @ % ) ( … J ) ( " - ) "

1f a l'Y @ % ) ! J t k b #- 'Y ( ) > 9€ > h ^ F ) 6h M" + b #- 'Y

.^ F ) l'Y @ ' ! |! M O > ) " 'Y b

#-l'Y @ ~ 6(n ( ' ) M 6h t … S ) 'Y ( ) Z ) 9* S ) ) " % '" i% j

i }m pk % ž!

EP K 6h ( #- ) " l'Y @ 6g 9J h > %+ s e & ) b #-l'Y @ ' )$# " J ! P x

@ ' ‡ # x 6(n )" ' #V ' ‡ • 9+ F (x M " ‡ J8 6(n &' !• ) " ' ‡ # ( ) Z ) ƒ 6(n % &' 9J 6(n 58 O ' )

l G # x J $ O Z ) 9* #V G ' ) #- ! Q ' % # x a ) M" + b Q ' % Z ~ ) ' ) G

l'Y # x 6h M" + b S ) 'Y ' ) #F " 'Y - ' %

T3 9ƒ ?d e & ) b #- l'Y @

' ) 6>• ' ‡ # P • G # P K • ' % # P

9J 'Y # P ? ] ) $ a ) 6h ( ) 9I l'Y @ J K K

7 h #- l'Y @ ' - #o ?• P * ?9 + ' ' ‡ # • + ' G # • ?9 + ! ' ' ' % # 9J + $ a ) ' 'Y #

Q- #o ? ^ F ) " %+ s“ A-Z”, “a-z”,”0-9”,”+ / ” ] ) - ) J ? %+ s r+ Fx

SVRMGR> SELECT deptno, ROWID 2> FROM scott.dept;

(138)

- - 10 AAAArsAADAAAAUaAAA 20 AAAArsAADAAAAUaAAB 30 AAAArsAADAAAAUaAAC 40 AAAArsAADAAAAUaAAD rows selected

' ) 6> x

AAAArs J ) " b @ ' ‡ # AAD J ) " b l G # AAAAUa J ) " b Q ' % # AAA J ) " b l'Y #

J hi i … pk ž v i pk % ž!

r3 #- )# t > h \# ' ) #- ! > h ^ F ) @ ‡ X # 6h M" ! Z 'Y / " l L X # ' ) ! a ) 6h M" G / " Q ' % X # a ) 6h M" Q ' % Z 'Y 9J ) " l'Y X # M" + M" 'Y ' ) #F " 'Y

% ž! qi • m [%r r} % ž! \

T3 9ƒ DK / * & b l'Y @

< (* 6=8 b > ^ F ) & ) l l'Y @ 1- l l'Y @ ^ F ) ? 9J % ) Z ) " @ ‡ X # e & ) J8 ^ F ) ' ) D9J " ! (* 6> @' L X # J O ' ) & " ! (* b

% ) ' ! |! > K G

1f a 6o % _ ! F ) * & \ ) " ^ F ) ! ml ( ) L X # ' ) #V l l'Y @ 9€ 6(n ^ F ) ' ) #- ‡ ir+ F (

' ! ' M j J8• " M # " 'Y „ ) \# a ) #-)# Z " 'Y

14.2.2 T p h?p (collection)

E> % h ! n! ^ F ) 6h ( " > + f! & ' ) " 'Y b #-r y s % h ! n! + n! J #- J# P

• q • [ k k k \

r ) a ) 6h ( " ) " Z #- $ (n ) p " $• 9+ F ( $ '& b " % " J )

r ) > " 6f + x :J #- # ) > Z s " $

O " J ! P ' ) # ) > a ) % h

1V J ! P > #- t $ i Mj• 6> J ' $ ( ) Z ) 9* + b J ! P ' ) # )• B ) 6(n 6" $ S K v

.$ * O b " J ! P ' ) # ) + J %+ (* b # )

' ! |! # ) > h > %+ (* 6] r3 8• )(R )y B ) J " r0ll0u 7+ (* s 6& b r0ll0u P 6(n t % #2

(139)

q• l• k [ r r} kqlr\

E" ) O! #- ! ( ) Z ) g #- ) ( J #- - ' ) #-) % " E> h ^ F ) ! ( ) ! "! J8 6h ( #- (n ) * " ) i9+ F ( " # i#F j ' ) #- J )j

X > " 6f + x

1- J #- ! % ) _! M ! " ) 'Y E" 'Y ' ) > a ) #- O B

E" 'Y ' ) 6(n ( " R 9* 9* ) 9J > #- ' p p * 9* 'Y ( ) Z ) )

E" # $ ( ' > h 6(n t )(R ) > ) * & c ) " )

14.2.3 Ki>u quan h (REF)

7 h 6(n a ) ( J ' p ' ) r ^ F ) % h J8 6~ p † y

OBJECT r+ F• #V # ' ) 6f J ) > h p # #- J ) ' )

)PRODUCTS• #J % ) P ( #o b " ! H#

y }{ l t } zv Œ }„ hi jk [8 r r• r} $ fr\

' ! |! )(R ^ F ) ) g % h 9J ^ F ) B ) ' ) Z ) F )• ^ F ) 6f + J8 P y † y OBJECT

14.2.4 Ki>u d li u TIMESTAMP

' ) ! d• > 4# #- % h #* • )y J % h 1C 01< h J8 ' ! |! ( • # 9* O! + M" d $ = ! = b ) =8

) O! #- $ J# ! F 9F ' 8h 6] % h x TO_TIMESTAMPx 8h 6] ) ) # #!

TO_TIMESTAMP_TZx 8h 6] ) J # #! > %•# # }' TO_DSINTERVALx 8h 6] ) J @ ' '

TO_YMINTERVALx 8h 6] ) J u ' 1'

TO_CHARx 8h 6] ) % & )

EXTRACTx 9I " ) " 84 P i & ) #- $ v # j ^ #- ) " # 8! ! ' u • 1' • @ 8• T' • • ' • # z' mT' • # z' m1 • # z' ml ) ' • ' # z' m0QQl

r+ Fx

SELECT EXTRACT(YEAR FROM SYSDATE) FROM DUAL;

14.3.QU N LÝ CÁC TABLES

14.3.1 T o table

> h &' ) = : EB ! "!x

CREATE TABLE [schema.] table

(column datatype[ , column datatype ] ) [TABLESPACE tablespace]

(140)

[LOGGING|NOLOGGING] [CACHE|NOCACHE] r* x

schema t #ng ng v i user s h u table

table tên c a b ng t o

column tên c a c t b ng c n t o datatype ki u d li u cho c t t #ng ng TABLESPACE tên tablespace ch a b ng

PCTFREE không gian dành riêng m i block (tính b.ng n v %) S d ng ch a hàng l n lên update

PCTUSED xác nh gi i h n d i c a không gian s d ng block

INITRANS xác nh s giao d ch c thi t l p cho m i block MAXTRANS xác nh s giao d ch l n nh t có th thi t l p cho

block m c nh 255

STORAGE quy nh kích th c c a khơng gian l u tr , xác nh xem có extents s+ c thi t l p cho b ng

LOGGING ch nh vi c t o b ng s+ c ghi vào redo log file

NOLOGGING ch nh vi c t o b ng n p d li u vào b ng s+ không c ghi vào redo log file

CACHE ch nh vi c truy xu t blocks c a b ng c thi t l p vùng m có th c hi n full scan table

NOCACHE ch nh blocks c truy xu t b ng không c t vào danh sách LRU vùng

m có th c hi n full scan table r+ Fx

CREATE TABLE employees( empno NUMBER(4),

last_name VARCHAR2(30) deptno NUMBER(2)) PCTFREE 20 PCTUSED 50

STORAGE(INITIAL 200K NEXT 200K PCTINCREASE MAXEXTENTS 50) TABLESPACE data01;

z ‡œ

1V > #- < # 8

X ) " MINIMUM EXTENT 6(n t ' ! % # - ) %+ (* )• ) " %+ (* ƒ 6(n J# ~ #- - $ P ) " b MINIMUM EXTENT

X p # 6I [NO]LOGGING - + ')) ) b ) ƒ 6(n 6f #f ' - + ')) ) b ! Z ) 6>

X ) " MINEXTENT 6(n t #- ) " * 9J ! Z I G • 5" # - ) ƒ s I G % " ( ) Z ) 9*

!

X4 6f " ) " ! )• % ) 6f " ) l' % ! •

#!' ! M !

.^ F ) H 9I %+ (* # - ) i M zj J #- - $ b 5*DB_BLOCK_SIZE 6h ) # h s ! = # ' )

eh = ) ' O s 9O 'J - )• P ! ) $ M

(141)

$ (n ) " ' % 6(n 6y #V % ! ' s 6y ! |! M O G b I J

1 6ICACHE t a ) ' " ) > %+ (* p 9J (R ) M 84 6(n 9O $ &( Qk s t r qz• k

E &8 # ) E y ‡ š™E

E y S " c O# B E y E ' ) ! P X Y ; QO# B

? X ! 9J' " ) ' ) ! P / • ' ) • 9J ! ' D QO# B E

14.3.2 Thi t l p giá tr PCTFREE PCTUSED

, $E%((

7 ) " PCTFREE * % ) ) J ' ƒ * % ) ) ' ! ! ) " J8 * 6h s ! ~ ) ' #- $ (R ) n!x

> I - ) " NULL B 6P ( ) 6> > & 6(n ! #- ) " % " NULL

E" - ' ) 6(n # - ) %+ (* #V % > 6(n ! #- ) " % " > 6- - ) *

1- ) " PCTFREE * ƒ J# ' # 6- J ) ' ) ' % O! 1V ' % ƒ ' ! |! > + J ) 6(n (

, $82(

# $PCTUSED 6(n M" \# # ' ) O! 6b $ (n ) ' % $ ) ! F 9F ) ( b E" ' % ) O! ' 6(n O8 S #- " " ' % V ) P 4# ' % 6h ( • ƒ 3# #- Q ' % $ ) ! ' ' )

" " ' % V ) J8 6h ) O! ' " 3# % # + M ' % 'f J 3# O8 #- ' % V ) ' ) " 'f 3# $ a ) b "

> h ^ F ) ) Z (* 6=8 6h M" ) " b # $PCTFREE / " b # $ 6(n + ) Z J8 > h J# ) # R ) 3# % # ' ) " " ' % V ) 9J { ) % { ) 3# % # % P 4# % ) ) ^ F )

ƒ u … i , $E%(( , $82(

T3 9ƒ D E2 ) Z + <E LlCC 9J <E W.C@

o ‡œ

(142)

14.3.3 Migration (di trú) Chaining dòng d li u

k [} o\ }¥ }{ l t

X ) " PCTFREE6(n % &' #- ) " p ƒ > h % ) 6b % ) ) P ' ) 5" { ) ( ) b " ' % i9+ F ( ! ' ) " 'Y

#-% " > 6- - ) * j 6>• ' ƒ 8h 'J - 'Y ) #- ' % #* 9J 6] ' p S ' % „ ) ' % #* " J8 )' J 5" # ) ' i Bj b

#-'Y s B #- 'Y• { ) 3# % # " 'Y ƒ ) # ' P ! 5| ' % 6h M" 'Y P 3#

k }¥ }{ l t

T (n ) ) " 'Y M % #- 'Y 5" * 9J' #- ' % e I J8 M % 'Y 6> Z " - > %+ (* * ' ) (R ) n! J8• ƒ " 'Y J I 6'& p i)y J %j 1V % 6(n ( ' ) #- ' % a ) 9* )

' p 6h M O > ! n! I % ' ! |! ( 6(n 'J - b 'Y E> h ) # h (n ) ) " 'Y \ ) " 6f ) " %+ (* b ' % J *

'f „ ) > h " " J I p #J & " p J8 > +

-14.3.4 Sao chép m t tables

> h ^ F ) = CREATE TABLE6h ' |! #- ) c & x EB ! "!x

CREATE TABLE [schema.]table [LOGGING|NOLOGGING]

AS Subquery r+ Fx

CREATE TABLE new_emp

STORAGE(INITTIAL 200K NEXT 200K PCTINCREASE MAXEXTENTS 50) NOLOGGING

TABLESPACE data01 AS

SELECT * FROM scott.emp; z ‡œ

E" # 6I TABLESPACE, STORAGE ) ^ F ) " ' % > h 6(n t % &' ) ^ F ) # 6INOLOGGING # $ p " ) ') ' ) ' ') G 9J { ) $ 6- &' )

7 s ' |! " • " ' i J ) - j• )) i#- b F 6(n s 6- ) %+ '& % > ' " j 9J ! ) i58I j )$ ƒ % ) 6(n ' |!

) #* eh > 6(n ) Z J8• ! &' \ )

X #- ' # 6o 6(n 58 J NOT NULL ' ) )$ • " - ( ) Z ) ' ) ) #* „ ) ƒ 6(n 58 JNOT NULL

14.3.5 Qu n tr columns table

> h 6] O B b ) ! 9J' O B b ^ F ) = ALTER TABLE6h ^ 6] O B b

r 6] O B b ' )c#x 4# #* ' #

(143)

ef 6-UNUSED ' ' #

T3 9ƒ D 6] O B b

$ | |• l | EB ! "!x

ALTER TABLE table

ADD (column_name datatype [DEFAULT expr], [column_name datatype], );

r+ Fx

SQL>ALTER TABLE Dept

2 >ADD (job varchar2(30)); Table altered

$ k h’ n o |€ l | EB ! "!x

ALTER TABLE table

MODIFY (column_name datatype [DEFAULT expr], [column_name datatype], );

r+ Fx

SQL>ALTER TABLE Dept

2 >MODIFY (ename varchar2(50)); Table altered

J q• l |

Q_ 6P S ! K K K • ' ! |! > h M'" * " - % ) ~ P ^ F ) ' ) #- • ' )c# Mv' ) z r J8 ƒ J# ) ! > ) #- ! P 9a ) % ) ) ' ) eh > h s 6(n J8 W P ! 6(n

O! 58I ALTER ANY TABLE > - P M'"

8 8• % ) h M'" O " - ' ) #- M'" " - ' ) " ' SYS

eh M'" ' # s = ALTER TABLE DROP COLUMN r+ Fx ['" - SAL ' ) ) #!x

ALTER TABLE emp DROP COLUMN sal; ['" - SAL9JCOMM ' ) ) #!:

(144)

}n x ƒ Œ }„ c r}

/ $ ) ( M'" ' # • ' " J8 „ ) t s 6(n _ 6P S ! K K K

eh s J8 ^ F ) = ALTER TABLE SET UNUSED #- - 6(n 6" O J W • b > ƒ % ) ~ ' ) ' Y 9J > h ^ F ) &

4 J8 6h 6f ' #- - #* ] )• #f % " • O " ' • M • -6(n 6" O W ƒ M'" p

r+ Fx e" O W ' - SAL9JCOMM

ALTER TABLE emp SET UNUSED (sal, comm);

eh M # ) 9I 3 ^ F ) " - ) ' ) & ) " • P 9O ' ) " Y x W.Cl_UNUSED_COL_TABS, ALL_UNUSED_COL_TABS 9J DBA_UNUSED_COL_TABS E- COUNT ' $ (n ) " ' # ' )

SELECT * FROM dba_unused_col_tabs;

OWNER TABLE_NAME COUNT - - - SCOTT EMP

1 row selected

J € }{ l t h¢ hz› h }n r}

eh M'" Œ - 6o 6" O W > h ^ F ) = ALTER TABLE DROP UNUSED COLUMNS

r+ Fx ALTER TABLE emp DROP UNUSED COLUMNS;

14.3.6 Chuy>n m t Table t i Segment hay Tablespace m i

' ) 5" s ( ) • ' ) (R ) M 84 6(n 4# #* • ! • r J8 ƒ J# ' ' ) { ) > 9(n 5" & #Z #J 6o O! ! " 6P • P ! 8h * )# ! #* 6h $ )

! F s 6(n

^ F ) = ALTER TABLE MOVE s ) J8

r+ Fx E 8h EMP * #- )# #* 9* " # $ ( #* ! a n! ALTER TABLE emp MOVE

STORAGE ( INITIAL 20K NEXT 40K MINEXTENTS MAXEXTENTS 20 PCTINCREASE );

14.3.7 nh ngh;a l i m t table ang online

' ) $ ) O! '• 62 % P P ! ) g & i G j " i)y J ”' ” j 6h = ) ' O ^ F ) b = 9O „ ) ( " ' "

% " ‰ ! d > ) O! 6h ) g & ) % > ) '& 6- ) v '

7 ) g & #- ) ' ) & ) ' • " = @1: 9€ > h 6(n 6> ƒ % '" i ' % j 6- M

r* % { ) #* 6(n ) O! J8• > hx 6] " # $ ( 6$ 9*

(145)

TV n 4# 9J U ! ' ) &' & 6h J# ) # s ! = 6'&

8 6] O B b #- ) (R ) #- Mv' ) z 4# 9J U ' # ' )

E s ) g ' ) 6- ' 6(n ) O! ' ) <:w :

DBMS_REDEFINITION 8I ' ! |! s ) J8 > J

EXECUTE_CATALOG_ROLE eh > 6(n 58I J8• P 6(n O! " 58I % " x CREATE ANY TABLE

ALTER ANY TABLE DROP ANY TABLE LOCK ANY TABLE SELECT ANY TABLE

qz• s t t hi jk lm kqlrœ

7 h# > h ' G i6 ) g & % ) s j \ ) " )y b F DBMS_REDEFINITION.CAN_REDEF_TABLE() ' ) (R ) n! % ) h s

' G b F 6> ƒ 9I #- V ' k ' % ) h s ' G

&' #- &# R i # j J8 _ - ! - a ) # 9* ) 6(n ' G 9* O " - + ( ) Z )

Q_ 6P G \ ) )y b F x DBMS_REDEFINITION.START_REDEF_TABLE()

&' " )) • M • 9J &' " ' ( ) Z ) # E"

' > # P 6(n &' ! 9J 6f & ) " E ' * % G % B i '#! 'f ' j % 5" G %

B • " )) • ' • M 9J " 8I )_ 9* # ƒ 6(n ! F

G " G " ' * # 6(n s

a ) 9J 8h & ) " b J8 J " G % B ; s b F DBMS_REDEFINITION.FINISH_REDEF_TABLE()6h % B

G ' ) " s b F J8• 6P ƒ ' %

6-M

? r 6] " M 6(n &' ' ) # (* ƒ 6(n s 6$ 9* 6o 6(n G

3… }„œ

r+ F # '& ) ' G b #- > J emp e=8 J - '&

' ! ' • 9J > " - > x empno, name, salary, phone ƒ 6(n G ' " (* x

E- salary # ! G ' 'G K 9J 6(n 6] J sal

E- phone M'" p

1- - #* • - deptno6(n 4# 9J' 9* ) " #f J K

s G & 6(n ! = % ' % ' ) ) " b - empno

/ ^ 6o &8 M' ) b F DBMS_REDEFINITION.CAN_REDEF_TABLE() 9J emp 6o `

J ) ' G

qz• s t r}r• rœ

(146)

(empno NUMBER PRIMARY KEY, name VARCHAR2(100), sal NUMBER,

deptno NUMBER DEFAULT 10) PARTITION BY RANGE(empno)

(PARTITION emp1000 VALUES LESS THAN (1000) TABLESPACE tbs_1,PARTITION emp2000 VALUES LESS THAN (2000) TABLESPACE tbs_2);

7 6- ) G

DBMS_REDEFINITION.START_REDEF_TABLE('u1', 'emp', 'int_emp', 'empno empno, name name, salary*1.10 sal')

&' " )) • M 9J ' ) m#! O " J ) - # * m#! 6I 6(n 6f J ! '• 58 " 58I O! ! " m#! ) $ ) ( J " 58I ' ) #!

s 6c ) - x m#! 9J #!

DBMS_REDEFINITION.SYNC_INTERIM_TABLE('u1', 'emp', 'int_emp');

7 B G

DBMS_REDEFINITION.FINISH_REDEF_TABLE('u1', 'emp', 'int_emp'); emp % '" 6- M % emp 6(n G 9* " - + #*

['" ) )

14.3.8 B ng – External table

CM J " G ( )'J #J M # > ( J

#-@ ' ) M (R ) J v' 9J % ) > M 6> 8I " ‡ J8 t J ŽSELECT TABLE’9J ŽREAD DIRECTORY’

# $UTL_FILE_DIR6(n ^ F ) 6h M" 6(R ) € * G r+ Fx

CREATE DIRECTORY external_tables AS ‘c:\oracle\oradata\external’; CREATE TABLE EMP_EXT (EMPNO NUMBER(4,0), ENAME VARCHAR2(10), JOB

VARCHAR2(9), MGR NUMBER(4,0), HIREDATE DATE, SAL NUMBER(7,2), COMM NUMBER(7,2), DEPTNO NUMBER(2,0)) ORGANIZATION EXTERNAL

(TYPE oracle_loader

DEFAULT DIRECTORY external_tables ACCESS PARAMETERS

(RECORDS DELIMITED BY NEWLINE

BADFILE external_tables:‘bad_emp_ext.txt’ LOGFILE external_tables:‘log_emp_ext.txt’ FIELDS TERMINATED BY ‘,’

MISSING FIELD VALUES ARE NULL) LOCATION (‘emp.txt’))

REJECT LIMIT UNLIMITED;

7 # 6o 6(n &' !• J8 > h 6(n ^ F ) 6h 9O ) $ ) ( " % " 9€ > h ^ F ) " J# " = ‡' J8•‘

„ ) > h # % ' " ) 9I M ' ) " Y x

(147)

DBA_EXTERNAL_LOCATIONS ' 6(R ) € * " G 9J ( #F ( ) Z ) ( ) B )

14.4.CÁC RÀNG BUCC (CONSTRAINTS) I V I TABLES

14.4.1 Ràng bu c i v i tables

7 &! 9J' • ' % ) t =# * ' ! |! 6( " ! a n! 9* O B b i (x a ) % h 9* - ( ) Z )• 6- * b 6( 9J' \# ' ) % ' ) ' ! |!• j #J ~ =# * + ! a n! 9I #f ') b " (

' ) i9+ F ( % ) h > )(R % " #J & > a ) #- #o $ ( ' ) $ )• ) " 6- ] % ) h ) " =#• j

eh # ' + ') 9J ! a n! 9* 84 P ) ! 9F b S ) J '" F h• ' ! |! )(R % 9J > h &' " J ) - ! a n! O ) ^ F ) " ' i J ) - 6$ 9* j

.^ F ) ' \# 6"! Z ) 6(n #- $ 84 P x

! " 58 _ ) ! 9F 6$ 9* ' ) S ) I #Z 6- % " x

% h# + ') b (* % s " ' " • ! S )

~ )

X){ M'" % J8 > * " - " % "

l m q € ¦ }{ l t

% q € ™ •

NOT NULL ) ' ! |! - ' ) ) " V )

UNIQUE ) ' ! |! > a ) f! & ' # ( ) Z ) ) " ~ ) % "

PRIMARY KEY '" + a ) 6h M" • ! = " ~ ) % " ' )

FOREIGN KEY lJ ) - ) % " e # ' - J8

! ( ) Z ) 9* ' ) #- % "

CHECK h# ! 9J' = ' #- 58 _ O

E" ' > h 6(n &' ! ' ) 5" &' 'f % 6o 6(n &' ) 9I " ' 6(n ! 9J ( ' ) '

14.4.2 Null / Not Null

:J J ) - 6$ 9* ' ) ' # J $ ) i j 'f % ) $ ) i ' j r+ F # 6I J ) - x

CREATE TABLE DEPT (

DEPTNO NUMBER(2) NOT NULL, DNAME CHAR(14),

LOC CHAR(13),

CONSTRAINT DEPT_PRIMARY_KEY PRIMARY KEY (DEPTNO));

14.4.3 Unique

E t J ) - O • " ) " b ' # t ' ) # 6I UNIQUE ' ) " 'Y b ! > ) " % " / " NULL J ' ! |! UNIQUE s #

-r+ Fx

CREATE TABLE DEPT (

(148)

LOC CHAR(13),

CONSTRAINT UNQ_DEPT_LOC UNIQUE(DNAME, LOC));

14.4.4 Primary Key

E t J ) - O i) $ ) UNIQUEj• % '" J & ) % '" UNIQUE O! ' O 1- t > h > #- PRIMARY KEY E" ) " ' ) PRIMARY KEY _ - ! NOTT NULL

EB ! "! % 6f CONSTRAINT #Z TABLEx

[CONSTRAINT constraint_name] PRIMARY KEY (column, Column ) EB ! "! % 6f CONSTRAINT #Z COLUMN

[CONSTRAINT constraint_name] PRIMARY KEY

14.4.5 Foreign Key ( Referential Key)

E t #$ J ) - # ) J8 9* % " • 'f ' ) + X> t #$ v ' 9J t J ) - ) FOREIGN KEY ) J8 9* PRIMARY KEY 'f UNIQUE KEY b ) % "

r+ Fx ) DEPT 9JEMP ) (R ) DEPTNO CREATE TABLE EMP (

EMPNO NUMBER(4),

ENAME VARCHAR2(10) NOT NULL, JOB VARCHAR2(9),

MGR NUMBER(4), HIREDATE DATE,

SAL NUMBER(7,2), COMM NUMBER(7,2),

DEPTNO NUMBER(7,2) NOT NULL,

CONSTRAINT EMP_DEPTNO_FK FOREIGN KEY (DEPTNO)

REFERENCES DEPT (DEPTNO) ON DELETE CASCADE);

S % '"ON DELETE CASCADE t ' ) & ) % '" J8 \# #F 6+ % M'" i ' ) )DEPTj ' „ ) s 6- ) M'" ' i ' ) )EMPj

14.4.6 Check

lJ ) - % h# ) " r+ Fx

CREATE TABLE EMP

(EMPNO NUMBER NOT NULL CONSTRAINT PK_EMP PRIMARY KEY, ENAME VARCHAR2(10) CONSTRAINT NN_ENAME NOT NULL

CONSTRAINT UPPER_ENAME CHECK (ENAME = UPPER(ENAME)), JOB VARCHAR2(9),

MGR NUMBER CONSTRAINT FK_MGR REFERENCES SCOTT.EMP(EMPNO),

HIREDATE DATE DEFAULT SYSDATE,

SAL NUMBER(10,2) CONSTRAINT CK_SAL CHECK(SAL>500), COMM NUMBER(9,0) DEFAULT NULL,

DEPTNO NUMBER(2) CONSTRAINT NN_DEPTNO NOT NULL

CONSTRAINT FK_DEPTNO REFERENCES SCOTT.DEPT(DEPTNO);

14.5.QU N LÝ KHÔNG GIAN L&U TR" TRONG TABLE

(149)

1- $ ) b # $ ( 9J # $ ^ F ) ' % > h 6] \ ) " ^ F ) = ALTER TABLE

EB ! "!

ALTER TABLE [schema.]table {[storage_clause ] [PCTFREE integer] [PCTUSED integer] [INITRANS integer] [MAXTRANS integer] r+ Fx ALTER TABLE scott.emp

PCTFREE 30 PCTUSED 50

STORAGE(NEXT 500K MINEXTENTS MAXEXTENTS 100); $ &( Qk s t r qz• k

E &8 # )

E 8h * B • c ! F 8h * # ( ) Z ) E y

8 6] " ) " ' ) ! P ' ) ; QO# B 0!!

9 z pk t k h’ k| ‘ lz {œ

E" # $ > h 6] 9J ( ) b 6] 6> ( x

NEXTx % ! " M ' ) ) " #* ƒ 6(n "! F )• %+ (* # - ) P s ƒ 6(n { ) PCTINCREASE

PCTINCREASEx % 6] # $ J8• ) 6] ƒ 6(n ) ' )

' / " #* ƒ 6(n ^ F ) 6h + & ) " b # $ NEXT% ! " M #* [| 9+ Fx > M 9* NEXT=10K 9J PCTINCREASE=0 { ) ) "

b PCTINCREASE J 100• M Z ƒ 6(n !10K• 9J M Z ƒ

J20K9J Z ! F ( % 4# " M

MINEXTENTSx ) " b MINEXTENTS > h 6] * ) " O %3 J' p \ ) ) " $ M R b ) / " J8 ƒ % ) ( ) ) % 6] #J ƒ ( ) % )

MAXEXTENTSx > h O %3 ) " J' * \ ) $ M R ) > ' )

• m œ

7 ) h 6] # $INITIAL ) ALTER TABLE

/ " NEXT t ƒ 6(n J# ~ #- ) " J - $ ) 84 P %+ (* b #- Q ' %

k| ‘ Œ }„ ql xœ

8 6] " # $ ^ F ) ' % \#x % # % ) ) ^ F )

/ # h 5" # ) ' 9J ) b ' % z pk t k h’ k| ‘ hšœ

PCTFREEx 6] # $này ƒ J# ( ) 5" ' ) ( )

(150)

100-PCTFREEj ƒ % ) ( ) % B ) 6(n 6( 9J' " " ' % $ ) i

G j

PCTUSEDx O Z #- 6] J' b # $ J8 6I ( ) O " ' % ' ) ! M'" #- 'Y• ' % Z 'Y 6> ƒ 6(n 6" O r ^ F ) " ^ F ) " ' % > h s 6(n 6$ 9* ' "

( #Z 6- ^ F ) " ' % ) # M $ ) (* ) " PCTUSED

INITRANSx 6] ) " INITRANS t ( ) " ' % #* MAXTRANSx 6] ) " J8 ƒ ( ) O " ' % ' )

14.5.2 C p phát extents b4ng tay (manually)

E" M > h O! ! " \ ) " ^ F ) = O! ! " s ! i)y J ! ( ) ! "! # v \ ) 8j \#x

e I % h 5" ! = " " M b " G % "

" (n ) # - ) s 6- ) %+ (* (* % &! 9J' EB ! "!x

ALTER TABLE [schema.]table

ALLOCATE EXTENT [([ SIZE integer K|M]] [ DATAFILE ‘filename ‘])]

r+ Fx ALTER TABLE scott.emp

ALLOCATE EXTENT(SIZE 500K DATAFILE ‘D:\Orant\oradata\orcl\data01.dbf’);

X p # $ SIZE• ƒ ^ F ) ) " NEXT_EXTENT > ' )DBA_TABLES 6h ! ) " ' " M #*

L 6(n t ' ) # 6I DATAFILE ! - 9I ! #J Z ) M # M|• % ) = ƒ V X # 6I DATAFILE % ) 6(n ^ F )

9 ƒ ! M #* ' ) #- G - ! Z ) M # M|

z ‡œ / " NEXT_EXTENT ' ) DBA_TABLES % ) J# ( ) 5" ! M \ ) % ) + & ) " b M ! ' % s =

14.5.3 High Water Mark

/ " b T ) q % ' #- t Q ' % $ a ) 6o S ) 6(n ^ F ) '

7 6o 6(n 9J' ' ) T ) q % 6(n 8h ' % $ a ) 6(n ^ F )

T ) q % % ) 6(n % p &' & ) " % M'" " 'Y ' ) / " b T ) q % 6(n ( ' ) ! P T b 6>

(151)

T3 9ƒ D T ) Y # %

r+ Fx 6'& #o <:w : 6=8 > h a ) 6h 3# 9J h $ ' % 6o ^ F ) ' ) 9J $ ' % % ) 6(n ^ F )

SVRMGR> DECLARE

2> v_owner VARCHAR2(30) := 'SCOTT' ;

3> v_segment_name VARCHAR2(30) := 'EMPLOYEES'; 4> v_segment_type VARCHAR2(30) := 'TABLE'; 5> v_total_blocks NUMBER;

6> v_total_bytes NUMBER; 7> v_unused_blocks NUMBER; 8> v_unused_bytes NUMBER;

9> v_last_used_extent_file_id NUMBER; 10> v_last_used_extent_block_id NUMBER; 11> v_last_used_block NUMBER;

12>

13> BEGIN

14> dbms_space.unused_space(v_owner, 15> v_segment_name,

16> v_segment_type, 17> v_total_blocks, 18> v_total_bytes, 19> v_unused_blocks, 20> v_unused_bytes,

21> v_last_used_extent_file_id, 22> v_last_used_extent_block_id, 23> v_last_used_block

24> );

25> dbms_output.put_line(INITCAP(v_segment_type)||' : '||v_owner||'.'||v_segment_name);

26> dbms_output.put_line('Total Blocks : '||TO_CHAR(v_total_blocks));

27> dbms_output.put_line('Blocks above HWM : '||TO_CHAR(v_unused_blocks));

28> END; 29> /

Statement processed Table : SCOTT.EMPLOYEES Total Blocks : 25

Blocks above HWM : 23

E B kx b F > )y * ! % ) # m! < % ) J8 6(n &' ! % &8 ! # 59J b F ! !

14.5.4 Thu h9i không gian không s6 d ng

X ( 6o O! ! " #- (n ) * " M ' ( ) > ( 6(n ^ F ) > h O8 & 9a ) % ) ) ~ $ ) 6> ) ) J8 % 6(n c ƒ & ` J )

(152)

T3 9ƒ D c % ) ) % ) ^ F )

EB ! "!x

ALTER TABLE [schema.]table

DEALLOCATE UNUSED [ KEEP integer [K|M]] / " KEEP t $ #Z T ) q % P 6h &

X T ) q % \# & #- M p ) " b MINEXTENTS• ƒ ) ! > ) " M \# ! + ) " MINEXTENTS

r+ Fx % MINEXTENTSŸ˜ • ƒ O8 & O " ' % % ) 6(n ^ F ) #Z T ) q % E B k \ ) M Z ;i9* @˜ j =8 ) R ƒ Z ; ' % X ) "

MINEXTENTS J ;6$ 9* ƒ % ) c % ) ) S M Z ;

z ‡œ

@' c % ) ) = ƒ ) ! > ) % ) ) % ) ^ F ) ^ F ) P s = J8 > h € ! = # % ) ) ' ) G eh "

(n ) 6> P % &' ) " MINIMUM EXTENT ' ! eh ) ! > ) 9a ) % ) ) (* T ) q %• # + % T ) q % J (* ) " MINEXTENTS P ^ F ) # 6IKEEP

14.5.5 Truncate m t table

#- ƒ M'" 'J - " 'Y ' ) 9J ) ! > ) % ) ) ^ F ) EB ! "!x

TRUNCATE TABLE [schema.]table [{DROP|REUSE} STORAGE]

( ) b ^ F ) = x O " 'Y ' ) 6I M'"

7 ) h ' % 6(n % 6o s = 93 = J8 _ - ! '## E" M ( ) Z ) b ƒ 6(n M'"

1- # " )'& % '" iFOREIGN KEYj % ) hTRUNCATE E" )) %•# 9* ƒ % ) M'" % s =

X ^ F ) # 6I DROPx O " M )'& S " M t MINEXTENTS6(n '& p

T ) q % 6(n % &' ƒ p ' % 6P ' ) / " b NEXT_EXTENT ' ) 6(n % &' & %+ (* b M > ) " M m

p O ' ) $ " M 6o c Z J MINEXTENTS=2 ) " NEXT_EXTENT ƒ 6(n % &' ) " b M Z b

(153)

.^ F ) # 6IREUSE 8DROP6I € M'" " M

14.5.6 Xoá table

1- > h M'" % % ) P ^ F ) % # $ ] Z & > EB ! "!x

DROP TABLE [schema.]table [CASCADE CONSTRAINTS]

7 #- M'" • " M ^ F ) J8 ƒ 6(n ) ! > ) X " M 6> J F B ) > h 6(n ! & s 6- ) 'f \ )

o ‡œ

1 6ICASCADE CONSTRAINTS J P J ) ' ) )'& % '"

14.5.7 Ki>m tra c u trúc b ng

9 s % h# + 'J 9Š b #V ' % ^ F ) # 6ICASCADE 6h

% h# O B b " M 9J s # |' ) " 9J

M b 6>

1F 6+ + b = J8 J $ ) %4 " ) 9I S 6>• ^ F ) ) J8 \# #F 6+ $ ( '" ^ F ) % ) ) (

1- $ " ^ F ) % " Jx

['" ) $ ) %4 9I " ) ' ) ' h# O B "

[" #Z 6- ) ' 9J E ) b " 'Y ' ) y| k n o kqlr

% % h# O B ( • O " ' % ' ) ) 6I 6(n % h# + 'J 9Š

9 % h# M # ' % > p ) % ) ) & #V P 6y ' % 6> # $

DB_BLOCK_CHECKSUM=TRUE ƒ 84 P s + '" % # 6$ 9* ! P b

' % (* % ) ' % 6g

EB ! "!x ^ F ) = % % h# + 'J 9Š b " ' % ' ) x ANALYZE TABLE [schema.]table

VALIDATE STRUCTURE [CASCADE]

o ‡œ b F ) " b F 6=8 6h ! = + " ‡ x

DBMS_DDL.ANALYZE_OBJECT phân tích m t i t ng ch nh DBMS_UNTILITY.ANALYZE_SCHEMA6h ! = + = " 6$ (n ) - 9I DBMS_UTILITY.ANALYZE_DATABASE a ) ! = + O " 6$ (- ) ' )

14.5.8 Phát hi n rows b migration

E= ANALYZE „ ) ~ > h 6(n ^ F ) 6h % h# " 'Y # ) ' 'f ) ' ) % )

EB ! "!x

ANALYZE TABLE [schema.]table [ COMPUTE STATISTICS]

[ ESTIMATE STATISTICS] SAMPLE integer ROWS | PERCENT]

† y COMPUTE STATISTICS ƒ ) $ ) %4 s 9J' ) b 'J

(154)

7 ) 9I $ ) %4 6o % > ƒ 6(n ! 9J' ) DBA_TABLES• (R ) CHAIN_CNT ƒ 6(n ! 9* ) 9I $ 'Y ) 9J # ) ' ' ) ) X > #- $ (n ) * " 'Y ' ) ) # ) ' 6> P 6(n ] Z 9J 6" ) " & ) = ANALYZE (

r+ Fx

ANALYZE TABLE VOUCHER ESTIMATE STATISTICS; T #ng #ng v i l nh: ANALYZE TABLE VOUCHER

ESTIMATE STATISTICS; SAMPLE 1024 ROWS

7 ^ F ) # 6IESTIMATE STATISTICS, t ' #f • > ^ F ) K 'Y

14.6.THÔNG TIN V2 TABLES

2 ) 9I " > h O8 S ' Y

T3 9ƒ D; ) 9I " ' )

14.6.1 Thông tin chung v* tables

eh O8 ) 9I )x $ 6$ (n ) • + b ! P b ) ' O " )

- 9I SCOTT a ) = x

SVRMGR> SELECT t.table_name, o.data_object_id, 2> s.header_file, s.header_block

3> FROM dba_tables t, dba_objects o, dba_segments s 4> WHERE t.owner=o.owner

5> AND t.table_name=o.object_name 6> AND t.owner=s.owner

7> AND t.table_name=s.segment_name 8> AND t.owner='SCOTT';

TABLE_NAME DATA_OBJEC HEADER_FIL HEADER_BLO - - - -

BONUS 1812 12

DEPARTMENTS 1811

DUMMY 1814 22

EMPLOYEES 1810

SALGRADE 1813 17

5 rows selected

14.6.2 Thông tin v* s6 d ng block thông tin chaining

(155)

SVRMGR> SELECT blocks AS HWM, empty_blocks, chain_cnt AS "Chained Blocks"

2> FROM dba_tables 3> WHERE owner='SCOTT'

4> AND table_name='EMPLOYEES'; HWM EMPTY_BLOC Chained Bl - -

1 23

1 row selected

(156)

Ch ng 15 QU N LÝ CÁC INDEXES

15.1.PHÂN LO%I INDEXES

M J O B =8 ' ! |! M O s ! #- 'Y ' ) M > h J# '& + J ') 9J k M ' % h ') € M O S Z ) F )• ~ M ' % h k 6(n ! = ' " Z #J M 6(n (

15.1.1 Index m t column Index nhi*u columns

1- M #- ' # t > #- ' # 6> # ) 9J' INDEX KEY r+ F M (R )EMPNO b )EMP t > #- - # ) 9J' % '" b M

M I ' # ~ )y J M ! Z n!• ) M J8 6(n &' J S I ' # ' ) • " ' # &' J M % ) P ! & r+ F M &' S - DEPNO9JJOB ' ) )EMP

.$ ' # s 6& ' #- M I ' # J %+ (* % n! b O " ' # % ) 9(n 5" w %+ (* b #- Q ' %

15.1.2 Unique index Non-unique index

1- M i M O j # ' \ ) % ) > 'Y J' - > a ) #-) " " ' # > ' ) M '" b M t > h p #- 'Y O

' )

7 " 9* M• 9* ' v M i M % ) O j• #- ) " % '" b M ƒ ( ) Z ) 9* #- ># " 'Y

15.1.3 Partitioned index non-partitioned index

E" ) (R ) ' ) 6I - '& ' v! '

< ' M i M ! = % j a ) ' " * • ( " #F M i M j b M J8 > h \# I )#

r ! = % ƒ ' ! |! #- M > h - ) I ! • ) # * & ) 5" % M 6(n M O 9J k

E" ! ' M 6(n ^ F ) a ) 9* " ! ' i ) 6(n ! = % j 6h { ) (R ) { ) 9J A k < ' M ƒ 6(n &' Z ) 9* #V ! '

J J8 6I ! * '& M 6(n ^ F ) J BY$%(( }rŠ9J B!, ', }rŠ

15.2.TE CH/C INDEX

15.2.1 B-TREE index

1f a P " M 6I ^ F ) Qv lCC M• ' ) ) Qv lCC (R ) ^ F ) % n! 9* #- M > ( " ROWID & #V % '" b M 6>

n o pk B—$%((

(157)

T3 9ƒ D? Qm lCC M

E" % $ " J % $ %|! ' M O M ' ) s ) # { ) b ) " % '"

i }m pk l }rŠ

1- h# 9J' b M ƒ 6(n &' J " J ! P 6=8x

C x ) ( $ ' # 9J ) % '" b " J ) ' ) ) ' # ) m9 ! x Z ) 9I %+ (* ' # # ) 9J' % '" 9J

! ' J %+ (* b 6>

l q @x J ) " b l q @ Z ) " % '" b M ~ … pk }rŠlrk•r

1- Qv lCC M ' ) #- ' v! ' x

/ " % '" f! & ( > I J ) > a ) ) " % '"

7 ) > M ( ) Z ) 9* " 'Y #J ) " b O " - % '" 6I \ ) NULL

l q @ 6(n ) * & ^ F ) 6h p " 'Y b • 93 O " 'Y 6I - 9I a ) #- )#

9 z pk t s “ lt h‘ • ! }rŠ

9 M # M| M b #V % > #- = @1: s 6> @(* 6=8 J #- $ ( ) b = @1: 6$ 9* Mx

7 b = i 4# #* j ~ ) ƒ • 4# #- M 9J' M

( ) Z )

r iM'"j " 'Y ' ) ƒ € * M'" " M ( ) Z ) ' ) ' % ) ) ^ F ) " 'Y M'" ƒ % ) a ) 6(n ' " i6 h# 9J' #* j ' * % 'J - " i6 h# 9J'j b ' % M'"

r ! " - % '" J % b 5" / " PCTFREE% ) ( ) M )'& S 9J' R h# &' M 1- h# 9J' #* > h 6(n 4# 9J' ' % b M ) % % ) 6b % ) ) t PCTFREE

15.2.2 Reverse Key Index

(158)

T3 9ƒ DD l M

7 • #- ) ' ) s { ) P b % '"• 9+ F ( $ ) $ #! ' ' )EMP• > h M (n ) _ ] " M 93 O " M 6(n ! M a ) #- + ' ) =8 M• ! ( ) ! "! a ) % '" )(n ƒ 9J ! = " " M ! I =8 M

r+ Fx % #o = D?d 9J' ' ) )• #- % '" d?Di% '" )(n 9* D?dj ƒ 6(n ( ' ) M• 9J = ! ' DD 6(n ! 9J #- % '" DDi% '" )(n 9* DD j ƒ 6(n ( 9J' b M r3 " #F i j b M 6(n ( 4 I

' % % " b M

X ( 9 _! M ! 6> > k ) g 6f ' ) " ) # { ) ' ) M #2 (R ) <

M a ) % '" )(n 6(n ^ F ) ' " #J > " ) " ) $ ) • 93 " % '" 9I #f S 9s ) & ƒ % ) 6(n ( )P % ^ F ) % '" )(n

15.2.3 Bitmap Index

T3 9ƒ D Q # ! M

Q # ! M i M ' % h " M& j J #- % h M 6(n ^ F ) ' ) #- $ (R ) n! x

7 > I 'Y 9J " - % '" > ) " % " O + e I 6> > ) g J > O + s % " ' ) ) " b " - r+ F Q # ! M + n! 6$ 9* " -) * + iX # X j

7 9O > % n! ^ F ) I # 6I ' ) ! P I % WHERE 6I 9O ^ F ) " ! |! '" ') l

(159)

n o pk B |kf ! }rŠ

1- Q # ! M „ ) 6(n ] Z ( J Qv lCC M• ( ) ! P " b #V ' ( #-o8 " ' #V % '" 93 " " l q @ 1V ' ) " Q # ! 6> ( ) Z ) 9* #- l q @• 9J ) " 6> 6(n % &'• I 6> > ) g J J ) > l q @ ( ) Z ) ƒ Z ) " % '"

2Œ }„ B |kf }rŠ

Q # !v lCC M ^ F ) 6h ! ! P " b " ' • ! P J8 ƒ Z 6'& # ! 6(n ^ F ) 6h M" J ) Z ) " % '"

7 > 6] " - % '" ' ) • " V # ! P 6(n 6] ' J ƒ " % '" " # ! )# ' 5" ! = 6'& " % '" J8 6~ p

s 'J - # ! )# 1- 'Y k # ! ƒ % ) h ! " ' % " % ' 6P % B

15.2.4 So sánh gi a B-TREE index Bitmap index

B• {k BY$%(( B |kf }rŠ

BY rr B |kf

+ n! 9* " - ! ) " * + n! 9* " - ! ) " p r ! s % '"

% ) 6_

E ! s 9J' (R ) % '" % " 6_ ) ' " 9O > ^ F )

# 6I l

T ' " 9O > ^ F ) # 6I l

T + 6$ 9* : < i '

! ' ) v 9F M^ k s j T +$ ) V n 58 66$ 9* @ i@ j' !!' # v Q ) 6=8 ' " ) Qv lCC 9J Q # ! M• Q # ! M 6(n ^ F ) I ' )

(R ) n! " - > ) " % " O +

r ! " - J# % '" ' ) Q # ! M ƒ # 93 Q # ! M ^ F ) ! ( ) ! "! % '" 6'& # ! i # ! )# ' % )j• ' ) % 6> ' ) #- Qv lCC

M % '" s " h# 9J' ( ) Z ) 9* S ) 'Y ) ‚

Q # ! M > h s " '& 6- ) 9* " '" & ) ') l 6> ^ F ) ! = 6'& # ! 6h s ' " S ) ' ) '" & ) l 9J 9I % J #- V Q # ! + O J8 ' ! |! ^ F ) V Q # ! ' ) =

8 9O > ^ F ) '" & ) ') l

X> ) Qv lCC M + n! ' ) #2 (R ) : < ' 9O " ) 6- ) ' ) % 6>• Q # ! M + n! ' ) #2 (R ) @ > ^ F ) I = 9O ! Z &! " * i ) j 9J g i j

15.3.QU N LÝ INDEX

15.3.1 T o index

1- M > h &' 'f ' b J 'Y b ) &' #- ' % " EB ! "!x

CREATE [ UNIQUE ]INDEX [schema.] index ON [schema.] table

(column [ ASC | DESC ] [ , column [ASC | DESC ] ] ) [ TABLESPACE tablespace ]

(160)

[ storage-clause ] [ LOGGING| NOLOGGING ] [ NOSORT ]

r* x

UNIQUE c s d ng ch nh m t unique index (non-unique index m c nh)

schema owner c a b ng ch a index

index tên c a index

table tên c a b ng ch a index column tên c t dùng làm index

ASC/DESC c cung c p t #ng thích v! cú pháp cho database khác

TABLESPACE tên tablespace mà index s+ c t o ó

PCTFREE khơng gian dành riêng m i block, c s d ng m t có i m vào m i c a index (new entries)

c t o

INITRANS ch nh s giao d ch thi t l p ban u cho m i block

MAXTRANS gi i h n s giao d ch có th thi t l p cho m i block (giá tr m c nh 255)

STORAGE tham s l u tr , quy nh có extents s+ c p phát cho index

LOGGING ch nh vi c t o index ho t ông tu n t trên index s+ c ghi vào redo log file

NOLOGGING ch nh vi c t o ho t ng tu n t index không c ghi vào log file

NOSORT ch nh row c l u database theo tr t t t/ng d n th oracle server khơng c n s"p x p hàng t o index

r+ Fx

CREATE INDEX scott.emp_lname_idx ON scott.employees(last_name) PCTFREE 30

STORAGE(INITIAL 200K NEXT 200K PCTINCREASE MAXEXTENTS 50) TABLESPACE indx01;

o ‡œ

X ) " b MINIMUM EXTENT 6o 6(n ) g ' ! • %+ (* b M a ) ' M ƒ 6(n J# ~ J #- - $ P ) " b MINIMUM EXTENT

X # 6I [NO]LOGGING p • - + ') b M #f ƒ ! F - 9J'

- + ') b ! #J M 6(n &' 6>

PCTUSED % ) 6(n t ' M• 93 " h# 9J' M ! 6(n ( ' s O • )(R a ) % ) 6(n ! |! I % h % #- M ' % 6(n ^ F )

'

X S % '" NOSORT 6(n ^ F ) % % ) 6(n {! M ! ' ) (R ) % '" = ƒ % B 9* #- V • V J8 ) $ ) ( s I = @1:

)

(161)

zã }Đ x m }rŠœ

To8 M # M| " (* ) € % &' Mx

M J# { ) $ 6- b " = 9O ( ) J# # $ 6- b " = @1: r3 • P ) # $ h M " ) M 8 6]

ef M ' ) " ! ) • % ) 6f M ' ) ! Z ' % )# • #!' )# 9J

eh J# ) # s ! = # ' ) " ! a ) Z M ^ F ) H %+ (* M J - $ b 5*DB_BLOCK_SIZE

T { ) > h { ) % ) ^ F ) # 6I LOGGING r3 8• P M # M| % ^ F ) # 6ILOGGING% &' " M *

r3 " h# 9J' ' M J p 6$ 9* " 'Y 6(n M M ' % ƒ > I h# 9J' ' #- ' % r3 8• ) " b INITRANS6$ 9* M > ) 6f * J ) " b # $ J8 ^ F ) M

eh ! " b ^ F ) M• &' M ' S ) - 'f ># - # ) ' ) # 6IWHERE b = 9O

r+ Fx

1 T o index t/ng t c truy v n tên nhân viên: SELECT * FROM emp WHERE UPPER(emp_name) LIKE 'JOH%'; L nh t o index

CREATE INDEX idx ON emp (UPPER(emp_name)); V i câu l nh truy v n bi u th c: SELECT a FROM t WHERE a + b * (c - 1) < 100; L nh t o index

CREATE INDEX idx ON t (a + b * (c - 1), a, b);

3 T o index h tr s"p x p chu i ký t d a ngôn ng c a t ng qu c gia:

SELECT * FROM t_table ORDER BY name; L nh t o index

CREATE INDEX nls_index

ON t_table NLSSORT(name, 'NLS_SORT = German')); S d ng index nhi!u c t khác nhau:

SELECT * FROM emp

WHERE UPPER(emp_name) LIKE 'JOH%' ORDER BY name;

L nh t o index CREATE INDEX empi

ON emp UPPER ((ename), NLSSORT(ename)); ! }rŠ i , $E%((

(162)

‰ 6=8 ) " ' #- - 6(n M b J ) 6(n • 9J' ) > h O Z ) " J' r3 ) " #* > h % ) \# ' ) o8 ) " 6o > E ' P ! t #- ) " PTCFREE ' r+ F &' M (R ) #o % " J ) ) '" ' ) (R ) n!

J8 P ^ F ) ) Z + 6h M" ) " b PCTFREEx

/ " s 6& > h O8 ' ) % ' ) R ) F h Œ ) & ( #- {#

15.3.2 M t s cách s6 d ng index

2Œ }„ }rŠ|€ zv |

r* " J8• )(R a ) t &' M #- " (R ) # ) = : 6ION ƒ ' - ' ) ) 6(n ^ F ) M

r+ Fx

CREATE INDEX emp_ename ON emp(ename)

TABLESPACE users STORAGE (INITIAL 20K NEXT 20k

PCTINCREASE 75) PCTFREE 0;

! }rhz ă l w k q [ k \

7 &' " J ) - UNIQUE 'f PRIMARY KEY ' " - ' ) • ƒ s 6- ) &' " M ( ) Z ) 9* - J8

8 ' ) #- $ (R ) n!• # $ &' " M ' \# #- ! ) 6h ' J8• &' M P 6(n )_ I #- "

(R ) # ) ' ) = &' ) r+ Fx

CREATE TABLE emp (

empno NUMBER(5) PRIMARY KEY, age INTEGER) ENABLE PRIMARY KEY USING INDEX

TABLESPACE users PCTFREE 0;

! }rŠ& l r

2 ) (R ) ' ) % &' M• " = @1: " 6- ) - > 6I &# R % ) s 6(n ' % 'J O &' M

eh > h ' ! |! s = @1: " 6- ) " - 6(n M• > V n M ' i M s j % J8• P ] ) 4# # 6I X: XC 9J' ' ) =

r+ Fx

ALTER INDEX emp_name REBUILD ONLINE;

CREATE INDEX emp_name ON emp (mgr, emp1, emp2, emp3) ONLINE;

! }rŠ r i |

7 ) t ' ! |! s " M s ! " - ' ) • ~ ' ! |! s " M s 9J' ) " b " J# "! F ) " - b

r+ Fx

(163)

S d ng cho câu l nh truy v n:

SELECT a FROM t WHERE a + b * (c - 1) < 100;

z ‡x :'& M J8 t 6(n ^ F ) ' ) " ! 4 eh ^ F ) 6(n M J8• P ! ! #- $ ) $ % &' ' ) ! # G x

QUERY_REWRITE_INTEGRITY6f JTRUSTED QUERY_REWRITE_ENABLED6f JTRUE COMPATIBLE! 6(n 6f J K K K 'f *

eh ^ F ) 6(n M J8• P 6(n ! 6(n s O B iANALYZEj % 6o &' M' ) M

15.3.3 T o Index khoá ng ?c (reverse key index)

> h &' " % M \ ) = CREATE INDEXx EB ! "!x

CREATE [ UNIQUE ]INDEX [schema.] index ON [schema.] table

(column [ ASC | DESC ] [ , column [ASC | DESC ] ] ) [ TABLESPACE tablespace ]

[ PCTFREE integer ] [ INITRANS integer ] [ MAXTRANS integer ] [ storage-clause ] [ LOGGING| NOLOGGING ] REVERSE

r+ Fx

CREATE UNIQUE INDEX scott.ord_ord_no_idx ON scott.ord(ord_no) REVERSE

PCTFREE 30

STORAGE(INITIAL 200K NEXT 200K PCTINCREASE MAXEXTENTS 50) TABLESPACE indx01;

E= J8 &' M % '" )(n ( ) s ( ' M ) (R ) )'& S 4# # 6IREVERSE

o ‡x S % '"NOSORT % ) 6(n ^ F ) ' ) = &' M % '" )(n

15.3.4 T o Bitmap index

EB ! "!x

CREATE BITMAP INDEX [schema.] index ON [schema.] table

(column [ ASC | DESC ] [ , column [ASC | DESC ] ] ) [ TABLESPACE tablespace ]

[ PCTFREE integer ] [ INITRANS integer ] [ MAXTRANS integer ] [ storage-clause ] [ LOGGING| NOLOGGING ] [ NOSORT ]

r+ F x

CREATE BITMAP INDEX scott.ord_region_id_idx ON scott.ord(region_id)

(164)

STORAGE(INITIAL 200K NEXT 200K PCTINCREASE MAXEXTENTS 50) TABLESPACE indx01;

o ‡œ Q # ! M % ) h J W

# $ % &' CREATE_BITMAP_AREA_SIZE 58 % ) ) ƒ 6(n ^ F ) ' ( " # ! )# ' ) - *• ) " #f b > J8MB• #- ) " * > h J# ' &' M

15.3.5 Thay 5i tham s l u tr cho index

1- $ # $ ( 9J # $ ^ F ) ' % > h 6] \ ) " ^ F ) = ALTER INDEX

EB ! "!x

ALTER INDEX [schema.]index [ storage-clause ] [ INITRANS integer ] [ MAXTRANS integer ] r+ Fx

ALTER INDEX scott.emp_lname_idx STORAGE(NEXT 400K

MAXEXTENTS 100);

( ) b 6] # $ ( ' #- M ) $ ) ( 6] # $ ' )• " ^ F ) ) O b 6] # $ J { ) ) " b MAXEXTENTS '

M

15.3.6 C p phát thu h9i không gian s6 d ng c8a index

$ ã lf x k } qâ k

E2 ) J8 P % 4# " M ' #- M (* % #- 5" • #- (n ) * " J ) 9J' ' ) ) 4# " M \ ) ){ s 6- ) 4# " M b

M

n lm x ƒ k nf f }rŠq© k

.^ F ) # 6I DEALLOCATE b = ALTER INDEX 6h ) ! > ) % ) ) % ) 6(n ^ F ) #Z T ) q % ' ) #- M

EB ! "!x

ALTER INDEX [schema.]index

{ALLOCATE EXTENT ([SIZE integer [K|M]] [ DATAFILE ‘filename’ ])

| DEALLOCATE UNUSED [KEEP integer [ K|M ] ] } r+ Fx

ALTER INDEX scott.ord_region_id_idx ALLOCATE EXTENT (SIZE 200K

DATAFILE ‘/DISK6/indx01.dbf’); ALTER INDEX scott.ord_ord_no_idx DEALLOCATE UNUSED;

o ‡œ

(165)

15.3.7 Xây d ng l i (Rebuild) index

E" M 6(n M=8 s ) & \# #F 6+ x

1- M #* 6(n M=8 s ) #- M 6o c &

" {! M ! % ) P % #- M 6(n M=8 s ) #- M 6o c & • % J 5" ƒ &' { ) '

M „ M'" % #- M #* 6(n &' ' ) 5" M=8 s ) & M % ) ) P J % ) ) ' M „ 9J M #* % 6(n &' J

E" 9O > h ! F ^ F ) " M ) c & ' ) % " M #* ) 6(n M=8 s )

‘ š y f • Š“ }s lm }rŠ

E" M ) c & P 6(n 8h * #- ! #* • ) J8 P % " M ' ) a ) #- ! 93 " ) " ' ‡ % " P ! = "

I 6g

1- M Z I h# 9J' M'"• (n ) J8 M 9* " M (n • 9+ F ( M (R ) $ Z s 6f J ) b ) 6f J ) " 6f J ) 6o 'J J ƒ M'" 9J #- 6f J ) #* 6(n 4# 9J' ' ) ) 9* $ 6f J ) * 1- M ) (R ) P 8h 6] ) M 9* % '" )(n

EB ! "!x

ALTER INDEX [schema.] index REBUILD [ TABLESPACE tablespace ] [ PCTFREE integer ]

[ INITRANS integer ] [ MAXTRANS integer ] [ storage-clause ] [ LOGGING| NOLOGGING ] [ REVERSE | NOREVERSE ]

E= l M % ) h a ) 6h 8h 6] #- Q # ! M J #- Qv 9J )(n & E" # 6IREVERSE9JNOREVERSE t ^ F ) 9* Qv M

r+ Fx

ALTER INDEX scott.ord_region_id_idx REBUILD

TABLESPACE indx02;

15.3.8 Ki>m tra tính h?p l c8a index

T3 9ƒ Dd h# + n! b M

(166)

7 h# O M ' % 9J 3# M # > ' % p ) % ) E= J8 % ) % h# M # M > ( ) Z ) 9* ' ) ) % )

! YINDEX_STATS9* ) 9I M

‰ ! d• > h s ANALYZE VALIDATE STRUCTURE 6h $ ( ) %

6 ) > @1: s

EB ! "! x

ANALYZE INDEX [schema.]index VALIDATE STRUCTURE

% s = ANALYZE INDEX 9O Y INDEX_STATS 6h O8 ) 9I

M ( ' ) 9+ F (* 6=8x

SVRMGR> SELECT blocks, pct_used, distinct_keys 2> lf_rows, del_lf_rows

3> FROM index_stats;

BLOCKS PCT_USED LF_ROWS DEL_LF_ROWS - - - -

25 11 14

1 row selected

] Z & M > > U " J ) M'" '• 9+ F % U DEL_LF_ROWS 9* LF_ROWS 9(n 5"30%

15.3.9 Xoá index

1- M P 6s M'" ' ) ) (R ) n! 6=8x 1- M % ) O ' Z ) F )

1- M > h 6(n M'" % s ' I • 9J &' & % 6o ' M' ) 1- M > h 6(n 6" O % ) n! iINVALIDj % > #- p ) ' ) 5" J' 6> 9+ F ( ' ' ) (R ) n! 6> M P 6(n M'" 9J &'

&

M p ) EB ! "!x

DROP INDEX [schema.]index;

15.4.THÔNG TIN V2 CÁC INDEX

15.4.1 Xem thông tin v* index

@ ' > " Y a ) 6h M # ) 9I M• Y ) F ) O ^ F ) JDBA_INDEXES9JDBA_IND_COLUMNS

(167)

.^ F ) = 6=8 % h# % h 9J & ) " b M b SCOTTx SVRMGR> SELECT index_name, tablespace_name, index_type, 2> uniqueness, status

3> FROM dba_indexes 4> WHERE owner='SCOTT';

INDEX_NAME TABLESPACE_NAME INDEX_TYPE UNIQUENES STATUS - - - - -

EMP_LNAME_IDX INDX01 NORMAL NONUNIQUE VALID

ORD_ORD_NO_IDX INDX01 NORMAL UNIQUE VALID

ORD_REGION_ID_IDX INDX02 BITMAP NONUNIQUE VALID rows selected

E- INDEX_TYPE t M J Q # ! X' # • ^ F ) = %4 b O

" M % '" )(n x

SVRMGR> SELECT o.object_name 2> FROM dba_objects o

3> WHERE owner='SCOTT'

4> AND o.object_id IN (SELECT i.obj# 5> FROM ind$ i

6> WHERE BITAND(i.property,4) = 4); OBJECT_NAME

- ORD_ORD_NO_IDX row selected

15.4.2 Tìm c t m t index

E= 9O 6=8 %4 " M b SCOTT9J t " ) 9J - 6> M 6(n M=8 s )x

SVRMGR> SELECT index_name, table_owner, table_name, column_name 2> FROM dba_ind_columns

3> WHERE index_owner = 'SCOTT'

4> ORDER BY index_name, column_position;

INDEX_NAME TABLE_OWNER TABLE_NAME COLUMN_NAME - - - -

EMP_LNAME_IDX SCOTT EMP LAST_NAME

ORD_ORD_NO_IDX SCOTT ORD ORD_NO

ORD_REGION_ID_IDX SCOTT ORD REGION_ID

(168)

Ch ng 16 N%P VÀ TE CH/C L&U TR" D" LI#U

16.1.GI I THI#U CHUNG

16.1.1 T5ng quan vi c n p d li u

T3 9ƒ ] ) 9I &! 9J ( Š

E> #- $ ! ( ) ! "! % " 6h > h ' i &!j 9J' ' ) b ' • " ! ( ) ! "! 6(n 6I ! ' ) ( ) J8 ' )c#

E2 ) F ' x &! s !

:• ' x &! S G M • % & ) s '

E2 ) F #!' 9J CM!' x &! S G ( 9* % & ) ' 58 r l k} r

@ ' > h 6(n ^ F ) 6h ' |! i '!8j S #- ) ) #- ) % " ' ) a ) #- ^ F ) ! ( ) ! "! J8 > h { ) $ 6- b 5"

' > h p 9a ) # • 6(n ) s ! 9J' ' ) 27 l k}r

• ' J ) F 6(n ^ F ) 6h ' 9J' ' ) ' ^ F ) " G )'J • ) F J8 (R ) a ) 8h S $ ) % " i ( L'M< '• • j 9J' ' )

(f !|f

E2 ) F CM!' ' ! |! " " ) ' ) ' Y 9J ' ) @ 9J 8h B ) 9J' ' ) #- G b I J ' & ) G ! = b

L ) F CM!' > h 6y ) F #!' 6h 6( 6y 6(n 9J' ' ) a ) #- 'f 9J' #- % "

16.1.2 N p d li u tr c ti p

7 &! s ! i ' j > h ^ F ) # 6I 0<<CX@ ( x EB ! "!x

INSERT /*+APPEND*/ INTO [schema.]table [ [NO]LOGGING]

sub_query ; ' ) 6>x

(169)

table tên c a b ng

sub_query câu l nh query l y hàng theo yêu c u @ ' t 6(n a ) % = INSERT INTO SELECT 6(n ^ F ) † y J8 % ) > % = INSERT INTO VALUES 6(n ^ F ) @ ' 6( a ) '

' ! ' 9J ! ' E2 ) F J8 ' ! |! % h# " M 9J "

' b )

• h€ l

7 ^ F ) † y LOGGING i J ) " #f j = J8 " h# 9J' ' ' ')• s '9 6P8 6b ' ) 5" ' > V

X NOLOGGING 6(n ^ F )• O " 6] ' ) ƒ % ) 6(n ( ' ) 9a ) # ' ')• #- $ ) p 9I ')) ) 6(n 6( 9J' ' ') ' " = # - ) 9a ) (

E 6-NOLOGGING ^ F ) ( " - + 6o 6(n % &' ' )

X #- $ ' " ! ' 6$ 9* ) M (R ) M 84 % &' - + NOLOGGING% ' 9J % &' & LOGGING% ' 6o 'J J

r l k} r f gf k }i x h• v m k h’ q•

'J - 6( 9J' ) ' ! ( ) ! "! J8 ƒ 6(n ' 9J' 9a ) t T ) q % X ) Z I ' % " J ) 6o M'"• % ) ) > h ƒ % ) 6(n

^ F )• 9O 'J - ) > h ƒ #

16.2.N%P D" LI#U

16.2.1 N p d li u b4ng SQL* Loader

.5• :' &! S #- G )'J 9J' ' ) E" 6f + b : ' x

E> h ^ F ) #- I G 6P 9J'

1- 9J ) 6P 9J' > h 6(n % n! 9J' ' ) #- ) ') ' ) 5" &!

E" (R ) 6P 9J' > h > 6- J 6] 'f (

@ 6P 9J' > h > " & ) % " N %+ s• ! = •

@ > h 6(n ' S " ! ( ) ( % " ( 6g • { ) S @ > h 6(n ' 9J' #- 'f I ) ' ) #- P &8

E> † y ' ! |! 8 $ ! 9J' ' ) " )

E" J# : > h 6(n ^ F ) ) 6P 9J' (* % 6(n ( ' )

/ " " - > h s 6- ) 6(n s #- ) 84 _ J' 6>• 9+ Fx ) " % '" P s > h 6(n 9J ( ' ) " - b )

(170)

T3 9ƒ :• '

27 ^ k}r Œ }„ •lr k h“

E' ' G iG I % h jx a ) 6h & ) ' 6P 9J'• ) 6P 9J " I % † y > h 6(n ^ F ) 6h ' #- ! P " ) 3# O8 ' ) G

6P 9J'

@ G iG jx Z 6P 9J' ' & ) 6(n ) g ' ' G < # G iG # $j J G † y > h ^ F ) Z " # $ ~ ) ' 5" '

Q L x 6(n ^ F ) ) F ' a ) 6h ) " ) '& p ' ) 5" ' i (n ) J8 > h M % " ) 6(n ' 9J' ' ) ) 9J '& % % h# + n! 6$ 9* " (R )j

:') L x 6(n &' :• ' Z #- ) " ) ' ) 5" ' @ L x J #- G > h 6(n &' % P • G J8 Z O " ) % )

' #o I % s y

16.2.2 Ph ng pháp n p d li u

T3 9ƒ < ( ) Z &!

(171)

r kl l k}

< ( ) ! "! ' ' ' M=8 s ) #- # ) " J ) 6(n 9J ^ F ) = INSERT6h ' ' ) 5" ' ' ! ( ) ! "! ' ' ' " ) 6( 9J' ƒ 6(n ! = + s 9J' " (R ) 6(n t 1- # ) b " ) 6(n

&' ! 9J • 9J' ' ) ) ' t b G I % h E" ) % ) ' #o I % b " (R ) 6(n t ƒ '& p 9J " ) % ) ' #o I % s

y 6f ƒ S $

E> h ^ F ) ! ( ) ! "! ' ' ' 6h ' 9J' ' ) " ) " ) % ) 6(n

2 ) ' ') 6(n 9J I % h - + LOG ' " ) 6s ' r l k}

' ! ( ) ! "! ' • ' M=8 s ) " ' % - * 9J O " ' % J8 s ! 9J' ' ) " 9a ) M 6(n O! ! " ' ) 6(n a ) ' ) 5" '

l ' ') % ) 6(n S % ) 6- ARCHIVE LOG• @ ' ^ F ) " (R ) 6o t 6h M=8 s ) 'J - " ' % b 9J s ! ) 'J - "

' % 6> 9J' ' ) " G " ' J8 > h p 9a ) # -*• M O 9a ) * /0 t 6h k # - ) " M 9J t ) " T )

q %

< ( ) ! "! ' ' ! |! &! ' 9* ! ( ) ! "! ' ' ' X ( ) ! ( ) ! "! J8 % ) ^ F ) 6(n ' ) #- $ $ ) O < P ! '

ƒ J8 ' " ) ! ( ) ! "! '

16.2.3 So sánh hai ph ng pháp n p d li u

Q ) 6=8 ' " ! ( ) ! "! '

r kl l k} r l k}

.^ F ) COMMIT 6h ) 6] (R ) B

.^ F ) " (

: > " ' ') ( ) Z ) E t &' ' ') ' ) #- $ (R ) n! 6f ' #o O " J ) - E t P ' #o % '" + • % '" O 9J

6 I % NOT NULL

s " )) INSERT %•# ' ) s " )) INSERT %•# ' E> h &! 9J' ) ' ! |! &! 9J'

W % " 9€ > h 6] • ' ) % &!

' ) % &!• " % " % ) 6(n ! |! ^ 6] b ) 6>

, z– f f lz { }{ l t

< ( ) ! "! ' ' ' ^ F ) = : 9J COMMIT ' O • 5" • #- # ) 9J ! ' J = COMMIT 1V ' > h #-9J ) '

< ( ) ! "! ' ^ F ) ! ( ) ! "! ) " ' % 9J' ' ) ' G • " 6f + % " 6=8 ) 5" O ! ( ) ! "!x

' ) 5" 6(n O • 'J - " ' % 6(n O 9J' ' ) ' E" ' % J8 6(n ) 9J' ' ) ) " T ) q % b ) 1- 5" O ƒ % ) % B ) '

(172)

z lm k h’

E' ' ' h# 9J' ' ') ) $ ) ( " = @1:• % ^ F ) ' • " h# 9J' 6> % ) 6(n ( ' ) 6-x

@ ' ) 6-NOARCHIVELOG

@ ' ) 6-ARCHIVELOG ( ) # $LOGGING=DISABLE i 6- ')) ) % % &' - + NOLOG ' ) ^ F ) # 6I UNRECOVERABLE ' ) G I % h

$ • l‰f q €

' ) 5" ^ F ) ' ' ' O " ' 6(n ƒ 6(n !• " ' J8 6(n ^ F ) ' ) 5" s " = @1:

7 s @ ' " ' 6(n ^ F ) ( x

E" NOT NULL ' 6(n % h# % " # ) 6(n M=8 s )

X)'& % '"i L' ) 8j 9J " CHECK ' DISABLE 9J 6(n ENANBLE s M' ) 5" ' \ ) " ^ F ) = ( ) Z ) ' ) ! I % h X)'& % '" t 93 B ) # " J ) % " " ) % " E" CHECK ' DISABLE 93 B ) > h ^ F ) " J# :• #- $ (n )

p " J ) 6(n • 9J' ' ) #- ) * ^ F ) ! ( ) Z ' ' ' '

7 '" + 9J % '" O i j 6(n % h# ' ) 5" ' 9J % % B 5" ' B ) > h B ) % ) n!

$ s t $ r ! r

' ) % " )) 6(n s ' ) 5" ' ' ' B ) & DISABLE (* % s ' \ ) ! ( ) Z E B ) > h 9€ ' ) & ) " DISABLE ( 6$ (n ) 6(n # * % ) h M O % % B 5" &8 EP M # M| ^ F ) ! ( ) Z ' ' ' % ' 9J' ' ) ) 9*

))

k} }{ l t l rr} kqlr

< ( ) Z ' % ) h ^ F ) ' " • t > h ^ F ) ! ( ) Z ' ' ' ' " )

7 x [ x \

' ) % s ' • " ' i) ' j % " % ) h ) & O %† 6] J' ) ) 6(n ' • )'& S ^ F ) ! ( ) Z ! '

16.2.4 N p d li u 9ng th i (Parallel direct load)

(173)

T3 9ƒ X&! 6c ) R

$… ¡ s pk “ lt

.^ F ) " G 9J' % " ' #V ' ' ) % ^ F ) ! ' • % " ' ' ) ! ' 6(n % &'• 5" ' s " (* 6=8x

1V ' ^ F ) #- #!' )# 6h ' S ! 6P 9J' X )

#!' )# J8 6(n &' ' ) ! #J ) \# 6> X ! Z #- 9J G #- > h t ' #V ' G #!' )# 6(n &' # $ ( ' " )# J8 > h 6(n t ' #f • " )# J8 ^ F ) " # $ ( ) $ ) 9* ) ) 6(n '

CM $ a ) ' ) #V #!' )# ƒ 6(n _ 6h c % ) ) % ) 6(n ^ F ) % ' % B

'J - " #!' )# 6(n % n! & J #- )# 9J' $ b 5" '

)# 6> 6(n 4# 9J' )# b )

m •

r ^ F ) ! ' > " & 6=8x

E" M % ) 6(n M # M| ' ) 5" ' • M'" " M (* % ' ^ F ) ! 9J &' & B ) % ' M' )

+ 'J 9Š b # • CHECK ' 9J " )) ! 6(n DISABLE 9J 6(n ENABLE & \ ) 6>

E" J ) t > h $ ! 9J' 9* c & ' ) ) ' " 5" ' ) ‚ % ) h % n! 6(n 9* X ' ) ) P ! ^ F ) =

TRUNCATE ) (* % ^ F ) ! '

16.3.N%P D" LI#U BFNG SQL*LOADER

16.3.1 S6 d ng SLQ*LOADER

(174)

.^ F ) = 6=8 6h s ' x EB ! "!x

C:\> sqlldr[keyword=]value[[[,]keyword=]value] r* x

% 8Y' J S % '"

9 J ) " 6(n )" ' S % '" r+ Fx

$sqlldr scott/tiger \ > control=ulcase6.ctl \

> log=ulcase6.log direct=true o ‡œ

X S % '" % ) 6(n t ) " P 6(n t 6B ) ( s ' ) = ª x hz› Œ }„ x mf }{ l t

$ê x ã

USERID W # 9J # % H ( ) Z )

CONTROL 4 b ' ' G

LOG 4 b ') G

BAD L ( " ) &! p ) i #f 6 J ' ' G j

DATA 4 G 6P 9J'

DISCARD Qp G Z " ) 6o 6(n ( ( ) % ) 6(n y

DISCARDMAX .$ (n ) $ 6 " 6(n ! |!

SKIP .$ (n ) ) 6(n p • ^ F ) 6 ' ) (R ) n! ! F &! % )f! V

LOAD .$ (n ) " ) ! F 6(n &! % SKIP ERRORS .$ (n ) $ 6 " ) V

ROWS .$ ~ ) ' ) # ) 6(n &' (* % &! i6$ 9* ! ( )

! "! &! ) (R )j

BINDSIZE @ ) (n ) $ i + ' 6 9 8 j a ) 6h &' # ) " ~ ) &! 9J' • 6$ 9* (R ) n! &! ) (R )

DIRECT :•:' ^ F ) ! ( ) ! "! &! s ! # $ J8 6(n 6f J TRUE

PARFILE 4 b " G Z " # $ &!

PARALLEL # $ t a ) % &! s ! E t $ (n ) c ) &! s ! > h s 6c ) R

FILE L Z #!' 8 )# ^ F ) 6 % &! s !

E" # $ ~ > h ) g ' ) G I % h

16.3.2 Parameter file (t p tham s )

' ) (R ) n! s &! 9* I # $ † y % " • % J8 > h )'# " # $ † y J8 9J' ' ) a ) #- G # $

(175)

<KEYWORD> = <VALUE>

# $PARFILE6(n a ) 6h M" b G # $ r+ Fx

SQLLDR PARFILE=example.par

V i n i dung c a file tham s example.par là: userid=scott/tiger

control=example.ctl errors=9999

log=example.log z ‡x

' ) 9+ F • M #! J b ' ' G v ƒ 6(n _ * ' ) ! P

E" S % '" ^ F ) ' ) G # $ + J " S % '" a ) 6h &! ( 6o >

16.3.3 Control file (t p i*u khi>n)

! I % h ' )c# " J ! P x

4 b ! 6P 9J' ^ F ) # 6IINFILE

.s n! J " ) ') S #- ) + ' ) G 6P 9J'• ^ F ) # 6I ( CONCATENATE9JCONTINUEIF

E" (R ) t ' )c# +• % h • # ^ F ) # 6IFIELDS

4 b ) 9J ! ( ) ! "! ' • M" > 6(n ' 9J' ) $ ) • " ) #* % M'" " ) 6o c & • 'f )_ 4# " J ) 9J'

) 6o c & • ^ F ) # 6IINTO TABLE

E" ) 6(n p ' #V ) ^ F ) # 6ICONTINUE_LOAD

e I % > h 6(n ^ F ) ' s y " J ) 6(n ' ^ F ) # 6I WHEN

E" - 6(n '

8 _ ' " ) " - • ^ F ) # 6IRECNUM•SYSDATE9J "! F ) " J# :

E" # $ ' ^ F ) ' ) # 6IOPTIONS

E t " # $ ( ' ! = 6'& #!' 6(n &' % ^ F ) ! ' E" '## i B € j ^ F ) I $ •vv•

E" † y ' ' (xSINGLEROWi ' " M J ) s 9J' J ) j REENABLE i6h ! & " ' % 5" &8 % B j• SORTED_INDEXES i t 6(n M_! ! (* j• UNRECOVERABLE i% )

" ) ' ')j o ‡œ

7 &' ) " NOLOG ' ) ) ^ F ) S % '"NOLOGGING ( ) 6( ) 9* ^ F ) † y RECOVERABLE ' ) ! I % h

(176)

€ ‘ ª x k Œ }„ l •lrœ

$ª x ™ •

INFILE [" 6 4 G Z &! 9J' • O • ' ƒ

6(n O8 ) ' ) ' ' G • ! + b S % '"BEGINDATA

BEGINDATA S % '" M" 6 6 h# _ 6P Z • S % '" J8 J P &! 9J'

READBUFFERS u4 P ^ F ) - * # 6h &! 9J' • ^ F ) ' ) ! ( ) ! "! '

BADFILE 4 b " G ( " % ) h &! 6(n 9J' ' ! " V ' ) 5" &!

DISCARDFILE 4 b G ( " ) p % ) &! 9J' ' % ) 6B ) 9* H &!

CHARACTERSET 4 ! %k s ^ F ) ' ) G

INSERT 4# #* ~ ) ' )

APPEND E • 4# #- ~ ) 9J' $ a ) b )

TRAILING

NULLCOLS e I ) "WHITESPACE 9J' - TRAILING NULLCOLS 6(n ^ F ) a ) 9* POSITION S % '" a ) 6h M" 6 9 + b P &!

CONSTANT ef ) " \ ) $ '

-RECNUM e # $ (n ) ~ ) 6o 6(n &! SYSDATE 9I ) " )J8 ) R R

TERMINATED S % '" M" 6 ! = " % B ENCLOSED S % '" a ) 6h M" 6 6(R ) ' r+ Fx X- ) b #- ' ' G

1 D li u c n p tr c ti p LOAD DATA

INFILE *

INTO TABLE dept

FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' (deptno, dname, loc)

BEGINDATA

12,RESEARCH,"SARATOGA" 10,"ACCOUNTING",CLEVELAND 11,"ART",SALEM

13,FINANCE,"BOSTON" 21,"SALES",PHILA 22,"SALES",ROCHESTER 42,"INT'L","SAN FRAN"

Ví d trên, s d ng d u ph y (,) ng/n cách gi a tr ng d li u n p vào database

2 D li u c n n p t file ‘ulcase2.dat’ LOAD DATA

INFILE 'ulcase2.dat' INTO TABLE emp

(177)

ename POSITION(06:15) CHAR, job POSITION(17:25) CHAR,

mgr POSITION(27:30) INTEGER EXTERNAL, sal POSITION(32:39) DECIMAL EXTERNAL, comm POSITION(41:48) DECIMAL EXTERNAL, deptno POSITION(50:51) INTEGER EXTERNAL) D li u file ‘ulcase2.dat’ là:

7782 CLARK MANAGER 7839 2572.50 10 7839 KING PRESIDENT 5500.00 10 7934 MILLER CLERK 7782 920.00 10 7566 JONES MANAGER 7839 3123.75 20 7499 ALLEN SALESMAN 7698 1600.00 300.00 30 7654 MARTIN SALESMAN 7698 1312.50 1400.00 30

0 ví d này, vi c xác nh tr ng d li u n p vào database d a vào v trí c a c t d li u m i dòng Tốn t POSITION (V trí u: V trí cu i) s+ th c hi n công vi c

16.3.4 Data file

L Z " ) 6(n M^ k ' #- & ) 6o ) g ' ) ' ' G

@ ' ) G (R ) J " & ) M ) (R ) " J8 > 6(n ' M!' S " % " '& ( L'M< '• •

r+ F G x M # 9+ F ! +

16.3.5 Các thành ph+n c8a log file

:') G 6(n &' 9J 5" ' 'J J #J ') G % ) 6(n &' 6> J ' 58I 'f % '' ) 6b % ) ) 6g

:') G ' )c# " ) x

< P x ' )c# ) 9I R ) &8• ! b ! P #I# E" ) 'J F x b ! G 9J ' ! G • " # $ ~ ) E" ) )x )• I % ' 9J ! ( ) ! "! '

2 ) 9I " (R ) 9J

-2 ) 9I ! x t " ) S $ 9J '& p 9J + ' S $ '& p

2 ) ' " )x $ " J ) 6o 6(n ' • $ " J ) S $ 93 V • $ " J ) '& p

2 ) ] ) n!x h x $ (n ) % ) ) 6(n ! ' # )• ) $ ) %4 ' O " G

R ) _ 6P 9J R ) % B 5" '

16.3.6 Các file +u khác

Bk} •lr

Q G Z " ) S $ ' ) 5" M^ k 93 #- ' ) " + ' x E" ) 6P 9J' > V r+ F ( & ) • 6- - ) b (R ) 5" *

7 ) h • 4# " ) 9J' Œ ) & ( &! 9J' % ) n! • " ' ! &#

k } •lr

(178)

16.3.7 Các h ng dGn s6 d ng load

.^ F ) " (* ) € 6=8 % a ) :• :' 6h ' ) # h 6(n V 9J { ) { ) ' ) 5" ' x

.^ F ) ! # $ 6h B * " # $ ~ )

" ! I % h 9J ! 6h ' ! |! ^ F ) & ! I % h ' " ' ' % "

! % ) ) ( s 9J' %+ (* b " ! " M ( s 6- ) ' ) % '

7 ^ F ) ' • " )# #!' 6(n ^ F ) " M ' #* E" M J8 6(n - 9* " M 6o > b ) 9J' B ' Q\ ) " M !

6P 9J' ' ) % '" b " M * O > h J# ) # % ) ) a ) ' '

r* ! ' > h t + b " ! = 6'& &# R 6(n ^ F ) '

9 e$ 9* #V ' ' t " G % "

l‹ Š• k x l k} }{ l t

7 5" ' % B % ) (R )• 'J - 6o 6(n ' R h# % B 6> ƒ 6(n '## % t V • 5" ' > h s ! ( 6h

'J J 5" ' x

X ) ' 9J' #- ) I ) > a ) $ ) 6(n M^ k • ^ F ) # $SKIP6h ! F 5" '

X I ) 6o 6(n ' 9J $ " ) 6o 6(n M^ k J % ) ( 6$ 9* " ) • ^ F ) # 6I CONTINUE_LOAD ' ) ! I % h t $ ) p ' #V )

7 h# " M 6(n 6" O J W T (n ) J8 M % M % ) O 5" 9* )• M'" M > & ) " ( &' & B ) % ' M' )

• † • l‹ x l k}

7 ) 6b % ) ) 6h ' x (n ) J8 M % 6g Z ) 6P8 % ) " " M O! ! " ) " MAXEXTENTS

Tp ) x & 9J ' &

@ % ) ' ) s t x 6o 6(n ' M' ) M ' ) & ) " • M'" 9J &' & " M

a ) f! ) " ' ) ! # % 8 % 8x (n ) J8 % ) J# p ) 5" ' ' ) B ) > hDISABLE " " ' 9J M & ) " UNUSABLE ' ) (R ) n! " ' V • > h ^ F ) " ) M ! ' 6h _ V 9J ^ B ) ' ) (R ) n! " M & ) " UNUSABLE• P 3# V \ ) " &' ' - J# M Q_ " V " ) M ! ' 9J ^

B )

BINSIZE5" px ^ F ) ) " * ' '

:V 93 9(n 5" ) " 6(n % &'x (n ) J8 M % $ " ) % ) n! 9(n 5" ) " ERRORS DISCARDMAX 6(n % &'• ) 84 = ) b

(n ) J8 J ^ F ) ! 6P 9J' % ) 6B )• % h# 9J ^ & ! 6P 9J'

16.4.TE CH/C L%I D" LI#U BFNG CÔNG C EXPORT VÀ IMPORT

16.4.1 Công c d ch chuy>n d li u

CM!' 9J #!' J ) F ' ! |! )(R @ > h 8h )

9J' + ' ) ) " ! % " )

(179)

T3 9ƒ ? @ 8h

ƒ „ (Šf

E2 ) F CM!' > h 6(n ^ F ) 6h &' " '!8 ') b " 6$ (n ) 6(n ) g 9J J " ! ! = CM!' > h ) ! 6g { ) S ƒ „ !|f

E2 ) F #!' > h 6y " ! 6(n &' \ ) ) F CM!' • '!8 " 6$ (n ) 6(n ) g 9J 9J' ' ) E2 ) F #!' % ) h 6y " M G " G 6(n &' ' ) O %3 & ) J' % "

2Œ }„ ƒ „ (Šf !|f

E2 ) F CM!' 9J #!' > h 6(n ^ F ) ' ) ) (R ) n! x

] Z & " )x b " ) P 6(n 8h S ! J8 ) ! % " E" ) Z I J ) # ) ' • #- ) > I ' % > O + " J ) 6(n • 9J'

E 8h S J8 ) % " x I J8 P % #- P 6(n 6] 1- 6(n M!' #- > h #!' 9J' #- % "

E 8h ) " x E" 6$ (n ) M" > h 6(n 8h S 5" ! " h ) ! H# % ^ F ) M!' O8 ! P ) O B 9J '& p ! P

CM!' 9J #!' ~ 6(n a ) 6h O8 S #- Z ) F ) : < 9J' ' )

q '

E 8h ) " < G' # " ! % " b

s 5" :') % !x 'J - #- 9J 6$ (n ) ' ) > h 6(n M!' • " M!' G > h 6(n ^ F ) ( J #- :') % !

16.4.2 Các ch Export

E2 ) F M!' ) O! % h M!' x W • •@

T3 9ƒ D E" 6- M!'

(180)

O " > h ^ F ) 6- ) 6h M!' " ) - 9I 6>• " 6(n O! 58I > h M!' O Z ) - 9I O Z #- J' ' ) • ^ F )

6-) 6h M!' x

EO B " )

@ ' ) )

O " M b )i t s 6(n % a ) 6(n ! = 58I j O " )) ' ) ) i t s 6(n % a ) 6(n ! = 58I j E" ' )

O " 58I ) • h€ rŠf r r

E 6- M!' ' ^ F ) 6h M!' - 9I x

W > h M!' " 6$ (n ) ' 6> J8 " ' ‡ - 9I 6I 6(n M!' )'& S " M 9J )) ' 6> ( ) & 6(n "! F ) '

b #- % " T'f " M 9J )) ' J8 ( ) " )) 9J M J8 & ' % "

E" )) 9J M 6(n &' " % " ( ) ) - 9I 6(n M!' E" % ) 6(n O! 58I t > h M!' 6(n " 6$ (n ) - 9I 6> • h€ E ll

7 ^ F ) 6- G 'J - " 6$ (n ) - 9I )'& S " " 6$ (n ) - SYS ƒ 6(n M!' E 6- J8 6~ p 58I 6f 9J % ) h s 9* #y E B k \ ) ' ) 6- M!' 58I b 6(n b F ) J ' xEXP_FULL_DATABASE

16.4.3 Export d li u tr c ti p Export d li u thông th ng

' ) ^ F ) ! ( ) ! "! ' % " x ' ' 9J '

T3 9ƒ E" ! ( ) Z CM!'

ƒ zv [ r kl l k}\

E' ' ' J ! ( ) ! "! #f 6(n ^ F ) :' 6h & ) 9J ) 9J' ' )

E' ' ' ^ F ) = : 6h O8 ' ) @ 6(n 6y S 6g 9J' ' ) 9a ) # 6>• " J ) 6(n 8h 9J' 9a ) # % h# ) " @ % % h# ) " ƒ 6(n 8h 9J' " ! M!'

(181)

@ ! ' O8 ' 9* ! ( ) ! "! ' ' ! M!' r* ! ( ) ! "! ! ' 6(n 6y S 6g 9J' ' ) 9a ) # 6> " J ) 6(n 8h

s ! 9J' ' ) " M!' ! ' ) % h# 6" ) " p ' ' ) " ' % % ) 6(n ) # ) " J ) a ) 9* > @ ` J ) ' ) & ) b "

! M!' 84 P • > " 6s 5" 8h 6] & ) @ 6(n 8h 9J' " M!' ! ' 9J " ! ' J8 ) 9J' ' ) " M!' G

E2 ) F #!' > h ^ F ) " M!' G 6(n &' O %3 #- ' ) ! ( ) ! "! < ( ) ! "! M!' % ) ( ) R ) b 5" #!'

16.5.CÔNG C EXPORT

16.5.1 S6 d ng công c Export

E2 ) F M!' > h )y ' 6-x @~ )

E 6- ( ) " E 6- ) !

• h€ }¥ lt [ ||k } l r\ EB ! "!x

$exp [keyword=]{value|(value, value )}

[ [ [,] keyword=]{value|(value, value )} ] r* x

keyword t khoá c s d ng câu l nh export value giá tr c gán cho t khoá

k| ‘ }¥ lt Œ }„ x !|f }{ l t

$ê x ~ hi ã

ANALYZE Y E ' ! |! s ANALYZE 6$ 9* (* %

#!'

BUFFER † '

6 I J

7+ (* b - # ^ F ) % M!' 7+ (* GG 6(n M" ' ) Z x

buffer_size = rows_in_array * maximum_row_size

COMPRESS Y / " J u• % #!' • %+ (* b M % &'

6(n 6f \ ) 9* %+ (* b )# R

CONSISTENT N / " J Y• O " ' " M!' t 6(n s ' )

#- v' '

CONSTRAINTS Y / " J u• " J ) - „ ) 6(n M!' a ) 9* ' ) )

DIRECT N / " J u• M!' s !

FEEDBACK

T h #Z 6- M!' • $ ~ ) 6(n M!' • & #V P r+ Fx FEEDBACK=10• E2 ) F M!' ƒ h

' #V P s ƒ M!' 6(n K ~ )

FILE expdat.dmp G ! > ! P # - ) J #!

FULL N / " J u• M!' 'J - eh s 6(n

J8• P 6(n O! 58I EXP_FULL_DATABASE

GRANTS Y / " J u• M!' " 6$ (n ) ' ) a ) 9*

(182)

HELP N / " J u• h " # $ 9J k ) g ( ) Z ) b B )

INCTYPE E" 6- # M!' iE" 6- J8 ƒ 6(n > F

h ! P j

INDEXES Y / " J u• M!' " M

LOG G ( " ) "' % M!' r+ Fx Exp system/manager LOG=export.log

OWNER e( " " " 6$ (n ) 6(n M!'

PARFILE G Z " # $ M!'

QUERY CM!'Ví d : exp scott/tiger tables=emp query = \"where ' #o #- I % J' 6> job=\'SALESMAN\' and sal\<1600\"

RECORD Y

/ & 6- J # # 9J' ' )

" ) $ )x SYS.INCEXP, SYS.INCFIL 9J SYS.INCVID

RECORDLENGT H

† '

6 I J 7+ (* + ' b ) 6(n M!'

ROWS Y E ' > M!' S ) ~ ) ' ) ) % )

STATISTICS ESTIMATE < = + 9J $ ) %4 $ (n ) " 6o M!' E> #- $ 6-xESTIMATE•COMPUTE• 9J NONE

TABLES : %4 " " ) M!' r+ Fx

TABLES=(EMP#, DEPT, MYDATA) TRANSPORT_T

ABLESPACE N E> M!' " !' ! % )

TABLESPACES # $TRANSPORT_TABLESPACE = Y•TABLESPACES ƒ a ) 6h %4 " " ! 6o M!'

TRIGGERS Y E> M!' " )) % )—

USERID

W # 9J # % H b s M!' E B ) 6(n h ' % & )xusername/password AS SYSDBA

8username/password@instance AS SYSDBA r+ Fx

1 Export tr c ti p b ng d li u

$exp scott/tiger tables=(dept,emp) \ > file=emp.dmp log=exp.log compress=n \ > direct=y recordlength=32768

2 Export d li u s d ng file tham s

> exp system/manager parfile=params.dat N i dung c a params.dat

FILE=dba.dmp GRANTS=y FULL=y ROWS=y

16.5.2 Gi i thi u m t s ch export

" % ! i ' ( j P 6(n (R ) M 84 6(n s E2 ) Q % ! > h 6(n s ' %† 8• 9* P 6P • 9€ ! s % !

(183)

% ! % " 9J > h "! F ) " 6- % ! J8 † - 9J' $ ) F h

! r|r kl (Šf [ • h€ ‚ z \

E 6- # t s % ! 6$ 9* " ) > s 6] ' 9* P s % ! )P 6> O ' ) 6- J8• 'J - b ) 9J ) g " ) „ ) ƒ 6(n M!' % ) ! = " ~ ) > 6] % ) > 6] i# A J ) > 6] • ƒ M!' 'J - )j E 6- # CM!' J 6- (R ) 6(n

s O ' ) $ " 6- M!'

r+ Fx / ^ P CM!' 6P • 6o s M!' 'J - ) 9I ) J8 & P Z • ^ F ) 6- # CM!' • % ) 6o > s ) #- ~ ) J' 6> O " ) > s 6] ) 9J " M %•# 9* ) 6> ƒ 6(n M!'

' ) P Z • > 6] ' ) 9J J8 E 6- # CM!' ƒ !

F M!' ( x

T3 9ƒ d CM!' 6- #

| lk r(Šf [ • h€ … l «\

E 6- # M!' ƒ s % ! 6$ 9* " ) > s 6] %h S P s % ! (* 6> 6- # '#! CM!' E 6- # M!' ƒ s

| O " P s % ! 6- # M!' 9J' ) G ) ‚

% ) P ! ( " G % ! 6- # M!' 93 % s % ! '

6- # M!' " G % ! ƒ ) 6•4 \ ) #- G #* ( ) Z ) r+ Fx ' ) 6- # CM!' P Z (• % > s 6] & 9J ? O

(184)

T3 9ƒ dK CM!' 6- E #

5 " O8 ' ) > 6(n s % ! P Z ( ) 9€ ! F 6(n Q % !

|flrr(Šf [ • h€ q€\

E 6- '#! CM!' ƒ ! % ! 'J - > ' ) r+ Fx ' ) P ;• s % ! 6- 'J

-T3 9ƒ d CM!' 6- 'J

-O8 ) ' ) 6- J8• % ) > 6] )3 ( ) „ ) 9€ M!'

r+ Fx s CM!' 6- #

> exp system/manager full=y inctype=incremental

16.5.3 Các tablespaces trao 5i

' ! |! > h 8h #- ! S #- )

#-% " • ) 6f h# !' !

eh 8h ' |! #- ! n! " ! • (* P 6( " ! 9I & ) " v' 8• ] ' |! " G ( ) Z ) 9* " ! J8• 9J ^ F ) ) F CM!' w#!' 6h 8h " ) 6(n ( ' ) ' )y J # i ) b " ) j E " G 9J # 6(n M!' ƒ 6(n ' |!

) 6+ ! '• P #!' " # J8 9J'

#* c ! & & ) " ' " ! 9S 6(n ' |!

(185)

TABLESPACES

16.5.4 M t s thông báo export: Warning, Error, Completion Messages

Elr

> h ( & O " ) "' i# ) j ' ) F CM!' ! " 9J' ' ) #- ') G • ) ^ F ) # $LOG E2 ) F CM!' ƒ ) & " ) J ) 9J

" ) V M ' ) 5" s M!'

Nk r k r [ ƒ q • q \

e$ 9* " V M % ) ) 4# y ) i ' G ' j + CM!' ƒ % ) S ) M!' ) r+ F• % > #- V M ' ) 5" M!' ) #- • M!' ƒ h

" ) "' V ' # ) c p & 6h ! F 8h ) " % " E" V % ) ) 4# y ) 6(n )y J " Y ) i "'j

CM!' ƒ ! " "' #V % > V % ) ) 4# y ) M

r+ F• 84 P M!' #- % ) c & • + CM!' ƒ 6( ) "' % ) > ( ) Z ) 9J ! F s " ~ &

> exp scott/tiger tables=xxx,emp

Export: Release 8.1.6.0.0 - Production on Wed Oct 15:25:15 1999 (c) Copyright 1999 Oracle Corporation All rights reserved Connected to: Oracle8i Enterprise Edition Release 8.1.6.0.0 - Production

With the Partitioning and Java options PL/SQL Release 8.1.6.0.0 - Production

Export done in WE8DEC character set and WE8DEC NCHAR character set About to export specified tables via Conventional Path

EXP-00011: SCOTT.XXX does not exist

exporting table EMP 14 rows exported

Export terminated successfully with warnings Ek kl ( r k r [ ƒ q l‹ | £ \

7 > " V ) 4# y ) iG ' jM ' ) 5" CM!' • ) F ƒ )S ) ' ) ! Z ) (R )• " V J8 M ' " V $ ) i ! ' #j ' J ) 84 • - * r+ F• % &8 E0 C[< :• G ! % ) &8• ) F CM!' ƒ ! "

2 ) "' V $ ) iG ' jx

EXP-00024: Export views not installed, please notify your DBA |flr r k r [$ ƒ q n \

7 CM!' 6o 'J O 9J % ) > V M • CM!' ƒ h ) "'“Export terminated successfully without warnings" X > O %† V % ) ) 4# y ) J' M ' ) 5" s • CM!' ƒ % B 9* ) "' "Export terminated successfully with warnings" > V ) 4# y ) % $ ) ! S )• % J8 $ ) ƒ 9I

2 ) "'"Export terminated unsuccessfully"

16.6.CÔNG C IMPORT

16.6.1 S6 d ng công c Import

(186)

T3 9ƒ d ^ F ) ) F #!' 6h 6( 9J'

7 s #!' • W P 6(n 6(n )" ' IMP_FULL_DATABASE E2 ) F #!' > h 6(n s " 6- x

$ª x ™ •

TABLES E 6- J8 ' ! |! s #!' " 9J ! ' 9J'

FROMUSER r* 6- J8• > h #!' O " ' ‡ ' 6> (

• ) • M • 9J ! '

FULL E t > " 6(n )" IMP_FULL_DATABASE ' #* > h s #!' 6- J8 J8• > h #!' 'J

-TRANSPORT_TABL ESPACES

E ' ! |! > 58I ( ) Z ) > h 8h 9J #!' ! n! "

! S J8 ) % "

ã h }Ơ lt EB ! "!x

$imp [keyword=]{value|(value, value )}

[ [ [,] keyword=]{value|(value, value )} ] r* x

keyword t khoá s d ng

value giá tr c gán cho t khố

k| ‘ }¥ lt

$ê x ~ hi ã

ANALYZE u E ' ! |! s ANALYZE6$ 9* (* %

#!'

BUFFER † '

6 I J

7+ (* b - # ^ F ) % #!' 7+ (* GG 6(n M" ' ) Z x

buffer_size = rows_in_array * maximum_row_size

COMMIT X < " P '## #V P 6( 9J' ' )

(187)

9J' • 6h 6] & • R ) #!' ƒ %|' J

CONSTRAINTS u E ' > #!' " J ) - 9J' % )

DATAFILES : %4 " " G ƒ 6(n 6( 9J'

FEEDBACK K

T h #Z 6- #!' • $ ~ ) 6(n #!' • & #V P r+ Fx FEEDBACK=10• E2 ) F #!' ƒ h

3 ' #V P s ƒ 6( 6(n K ~ ) 9J'

FILE M! #! G 9J' ! > ! P # - ) J #!

FROMUSER #!' " ' ‡ 9J' " # - FROMUSER

FULL X / "J8• J u• #!'P 6(n 'JO! 58I- eh s 6(n IMP_FULL_DATABASE

GRANTS u / " J u• #!' " 6$ (n ) ' ) a ) 9*

" 58I ) 6(n "! F ) 6$ (n ) 6>

HELP X / "Z ) b J u•B ) h " # $ 9J k ) g ( ) IGNORE X E> p 5#!' " V M 8#* 8 % )' ) 5" #!' 6h ! F

INCTYPE E" 6- # #!'

INDEXES u / " J u• #!' " M

LOG G ( " ) "' % #!'

PARFILE G Z " # $ M!'

RECORDLENGTH † ' I J

7+ (* + ' b K ) 6(n #!'

ROWS u E ' > #!' S ) ~ ) ' ) ) % )

SKIP_UNUSABLE_

INDEXES X

E ' > p &' " M 9J 6f > 9I & ) " W ' ) 5" #!' % )

TABLES :imp %4 system/manager " " ) #!' r+ FxTABLES=(jones.accts, scott.emp,scott.dept)

TRANSPORT_TABL

ESPACE X E> #!' " !' ! % )

TABLESPACES # $TRANSPORT_TABLESPACE = Y•TABLESPACES ƒ a ) 6h %4 " " ! 6o #!'

TOUSER T h " " " ' ‡ ƒ 6(n

#!'

USERID

W # 9J # % H b s M!' E B )

6(n h ' % & )x username/password AS SYSDBA username/password@instance AS SYSDBA

E B kx E t > #- # $FULL=Y 8OWNER=user 8TABLES=schema.table6(n t r+ Fx

> imp system/manager parfile=params.dat N i dung c a file params.dat:

FILE=blake.dmp SHOW=n

(188)

GRANTS=y ROWS=y

FROMUSER=blake TOUSER=scott

TABLES=(unit,manager) $ u s pk † |f

7 s #!' • " ' ‡ i6$ (n )j ƒ P (n 6(n 6( 9J' ' Z s x E" ) g 9I % h i 8! G ' j

2 Các nh ngh a b ng (Table definitions) @ ' ) " ) i j

E" M ( ) Z ) 9* S ) ) i M j ; E" ) ' • Y • ! ' 9J ))

? E" 6$ (n ) # - ) % " ( Q # !• G ' 9J '# M

+ P s J8 ){ S $ 93 s 6> ) 6(n #!' s J8 ~ ){ " )) s P a ) #- #- $ 6$ (n ) ( b F > h 6(n % h# % #!' 93 B ) 6(n #!' (* % " 6$ (n ) 6(n # h#

" 6$ (n ) 9* STATUS=INVALID9J '#! & B ) !|f |€ q• h ã m

7 #!' 9J' #- ) 6o c & • s b #!' > h ~ &' V # $ ) ( ) s „ ) M % > ' #- ) #J > # * + >

r3 k ' 6=8• " $ O J " # ' % #!' 9J' ' ) #- ) 6o c & E" ' > h 6(n & % #!' J )

„ ) > h ! = 5" #!' J# I P 93 P 6h " %

' #O I R )

$kqlrfk rhz› Œ }„ |€ h‘ z›

X #- > 6b 5' P " ) ƒ 6(n #!' 9J' ' ) a ) #- ! #J B ) 6o 6(n M!' ! % ) c & % ) 6b 5'

! • #!' ƒ &' ) ! #f b X % ) M O 6(n ! #f • " ) ƒ % ) 6(n #!'

1- ! = 6'& LOB t > h 6(n #!' 9J' a ) #- ! S 6> B ) 6o 6(n M!' 1- ) ) Z LOB ƒ % ) 6(n &' ( 'Y b " ) % ) h &' " 6$

(n ) ! 6> " ! = 6'& : Q 6o 6(n M!' o ‡

1- ) % ) Z LOB > h 6(n 8h S #- ! ) #- ! % " \ ) " ^ F ) ! ( ) Z #!'

zã }Đ } rf |f

.^ F ) " ! # $ 6h ( " # $ ) ' ) " # $

X > I '& 6- ) ! " ) ) 6(n M!' ^ F ) # $ CONSISTENT=Y• > ) &8 " 5" M!' * % > + " '& 6- )

' ) ) 6(n M!' • &' " ' % )# * ' 5" #!'

† y COMPRESS=Y ƒ 6'& #o 6h &' M • M J8 \ ) ] ) %+ (* b O " M ) 6(n O! ! " ' #- 6$ (n ) X 6$ (n )

> I J ) 6(n M'" M $ a ) > I ' % % ) 6(n ^ F ) • % ) P ! O! ! " I % ) ) ' 6$ (n ) 6>

(189)

16.6.2 Chuy>n 5i character set

y h’ k k r r x rŠf

< ( ) ! "! ' ' M!' ƒ ^ F ) t ' ' b

< ( ) ! "! ! M!' t ^ F ) b • b

M!' ' % ) ) $ ) ( b % M!' 6(n % &'• M!' ƒ h #- ) "'• P t ' ' 9J % 6- ) & 5" M!' CM!' G > Z #- R iG )j t 6(n ^ F )

y h’ k k r r x !|f

#!' ' 9J b 6+ > h % " 9* b

) c • ' ) $ ) J8 P > s 8h 6] b " ! @ 6(n 8h 6] ) b ' ' ) 5" #!' 6> 6(n 8h J

' ) 5" 8h 6] • O Z J' ' ) M!' G % ) ( ) 6( ) 9*

6+ 6I ƒ 6(n h #f e> J 6(n

(190)

Ch ng 17 QU N LÝ USER

17.1.USER TRONG DATABASE

17.1.1 User nh ng thành ph+n liên quan

2r |k

9 ) g " W 6>• ' ! |! )(R ^ F ) > h ! 9J' ) " J8 '# i ' # ' # I j ) g " 58I ! O " 6$ (n ) ' ) 9J "! F ) " 58I J8 ' S )

> ' )

T3 9ƒ d E" J ! P ' #

' r k r k | [ – • Š ‰ \

1V ! 9J' 6I (* M" 58I ! r J8 > h 6(n

s x

@

T I J

[" 58I ) 6(R ) #& )

8 • ' ) J J8 t =# * M" $kqlrfk r7 k [ m |u kqlrfk r\

! 5' I % h $ (n ) ! Z ) 9* % { ) ( k 6(n ! |! 6$ 9* #V ' )

r•k l $kqlrfk r[ kqlrfk r|~ hi \

:J ! #f Z " )# ' b ^ F ) 6h ( ' )

(R ) n! W % ) t … ! ) % &' )# $r|f k $kqlrfk r[ kqlrfk r k \

#!' ! J O! ! " " M ! F 9F ' ) _! M ! i ' j #V % s _! M ! b W 6>

' x [x k \

E" ' > h % '" i ' % j 6h ){ =# ! 9J' r J8 > h 6(n s #- " s 6- ) 'f ' I % h b

(191)

:J ) ) * & 6(n 6( ' #V 9I " J ) 84 b $ ) (x R ) ^ F ) E<W• M O 9J' w• $ (n ) " ' 6(n # $ • X ) ) * & 9I J ) 84 ƒ 6(n J %“ ' ) ( )

17.1.2 Database schema

# 6(n M # ( #- ! n! " 6$ (n ) ( • Y • • ! ' • 9J ! % ) • a ) > #- )_ I 9* #- J' 6> 1V % ' ) 6(n

&'• #- # ( ) Z ) 9* „ ) ƒ 6(n &' ! 9* a ) 1V t > h )_ I 9* #- # > a ) • 93 # 9J # I % > h a ) € '

T3 (* 6=8 ƒ %4 " 6$ (n ) ' ) # b #V

T3 9ƒ d @ #

17.2.QU N LÝ USER

17.2.1 Các b c th c hi n t o m i user

:s y # i a ) 6h ! j 9J M" 6$ 9* J8

E t " ! ' a ) 6h ( < = ] & #Z ^ F ) S ) ! /" " G ! 9J #!' ! ; &'

? < = 58I ! i! ) v 58I •' v Z j ' 9S &' !

17.2.2 T o m i user v i c ch xác nh n b i database

r* J8• ƒ ^ F ) # % H b 6h M" #V % % $ * 1V # % H b • ƒ 6(n ( ) ' ) ' 9J > > h % h# O A J ) #V % W % $ *

EB ! "!x

CREATE USER user

IDENTIFIED {BY password | EXTERNALLY} [ DEFAULT TABLESPACE tablespace ] [ TEMPORARY TABLESPACE tablespace ]

[ QUOTA {integer [K | M ] | UNLIMITED } ON tablespace

[ QUOTA {integer [K | M ] | UNLIMITED } ON tablespace ] ] [ PASSWORD EXPIRE ]

(192)

r* x

user tên truy nh p c a user

BY password xác nh c# ch xác nh n user b i database v i m t kh u truy nh p password

EXTERNALLY xác nh c# ch xác nh n user b i h i!u hành DEFAULT/TEMPORARY TABLESPACE

xác nh default/temporary tablespace cho user QUOTA xác nh l ng không gian t i a c p phát cho user

l u tr i t ng t ng tablespace t #ng ng T khoá UNLIMITED cho bi t không h n

nh s l ng không gian c p phát PASSWORD EXPIRE

b"t bu c user ph i ch rõ m t kh u m i user th c hi n k t n i t i database thông qua SQL*PLUS (Ph #ng th c ch có tác d ng user s d ng c# ch xác nh n b i database)

ACCOUNT LOCK/ UNLOCK

s d ng tu) ch&n lock/unlock i v i m i user m t cách t ng minh (m c nh UNLOCK) PROFILE dùng i!u n tài nguyên c a user

z ‡œ

7 ! † y PASSWORD EXPIRE ' ) &' • % ^ F ) :•<:W 6h % $ * • #V P % $ & ! &! #* # % H r ! ) (R ) ƒ

6(n ) "'x ERROR:

ORA-28001: the account has expired Changing password for PETER

Old password: New password:

Retype new password: Password changed

$ &( k š y s t r qz• k

.^ F ) )

E y W š™E

X ! 9J' ) b ' ) ! P / ! ) E t … & #Z ^ F ) ' ) ! P ' ; QO# B E

17.2.3 Thay 5i thu c tính c8a user

^ F ) = ALTER USER % s " 6] ( # % H • ' % ^ F ) % x

8 6] # % H % 54 # % H :' %wW ' % 6$ 9* " ' b

8 6] # % H ' S ) ! J# EB ! "!x

ALTER USER user

[ IDENTIFIED {BY password | EXTERNALLY }] [ PASSWORD EXPIRE]

(193)

ALTER USER peter

IDENTIFIED BY hisgrandpa PASSWORD EXPIRE;

:( kx % 6o ' % #J 9€ $ )_ ) % $ * ƒ ! " V ERROR:

ORA-28000: the account is locked

Warning: You are no longer connected to ORACLE $ &( k š y s t r qz• k

E &8 ) E 8h * B W

E y # ( ) Z ) E y W š™E ) '

; s 6] " & ) " W ' %• :' %• ' CM! ? X ! 9J' " ) ' ) ! P / ! ) D QO# B 0!!

17.2.4 Thay 5i h n m3c (quota) s6 d ng tablespace

' ) #- $ (R ) n!• > h 6] & #Z ^ F ) ! % x E" b 6> % ) h # - ) 6h ( 4# 6(n

E" Z ) F ) 6(n 6~ p ] ) 4# " M E" 6$ (n ) 6(n ] Z & 9J 6(n 6f I ! % " EB ! "!x

ALTER USER user

[ DEFAULT TABLESPACE tablespace] [ TEMPORARY TABLESPACE tablespace]

[ QUOTA {integer [K | M] | UNLIMITED } ON tablespace

[ QUOTA {integer [K | M] | UNLIMITED } ON tablespace ] ] r+ Fx

ALTER USER peter

QUOTA ON data01; $ &( Qk s t r qz• k

E &8 ) E 8h * B W

E y # ( ) Z )

X ! 9J' " ) + n! ' ) ! P ' ; QO# B 0!!

17.2.5 Hu- User

T U p % p EB ! "!x

DROP USER user [CASCADE] r+ Fx DROP USER peter;

Ho c

(194)

CASCADE ƒ U O " 6$ (n ) ' ) # (* % M'" W X> P 6(n t … % # Z I 6$ (n )

% ) h U 6(n " ) % $ *

17.3.THÔNG TIN V2 USER

> h O8 " ) * ' ) ' DBA_USERS 9J DBA_TS_QUOTAS

r* #V • > h M" 6(n " ) 9I & #Z x r+ Fx

SVRMGR> SELECT tablespace_name, blocks, max_blocks,bytes, max_bytes

2> FROM dba_ts_quotas

3> WHERE username = 'SCOTT';

TABLESPACE_NAME BLOCKS MAX_BLOCKS BYTES MAX_BYTES - - - - -

DATA01 10 -1 20480 -1

1 row selected

/ " v ' ) - MAX_BLOCKS 9J MAX_BYTES ' - J8 ( 6(n )" ) " (R ) #

T3 9ƒ d; ) 9I W ' ) '

T'f „ ) > h O8 " ) 9I ' b r+ Fx

SVRMGR> SELECT username, account_status, temporary_tablespace 2> FROM dba_users;

USERNAME ACCOUNT_STATUS TEMPORARY_TABLESPACE - - -

SYS OPEN TEMP

SYSTEM OPEN TEMP

DBSNMP OPEN TEMP

SCOTT OPEN TEMP

(195)

Ch ng 18 QU N LÝ THÔNG TIN PROFILES

18.1.GI I THI#U PROFILE

2 ) ! 'G J ! n! " ) 9I J ) 84 $ ) 9J ) * # % H b ' )c#x

R ) ^ F ) E<W iE<W # j E" ' " 9J' i w '! ' j

R ) ) t i # j R ) % $ iE' # j @ ) ( ) - * i1 #' ! j

E" ! J# 6c ) R iE' ' j

.$ P ^ F ) 9J R ) ^ F ) #- # % H i< Y' ) ) M! ' j : ^ 6] # % H i< Y' ' 8j

E M" # % H i< Y' '#! M G ' j '" ' ! i0 ' ' % )j

9 )" " ! 'G ' S ) #J ' 6> ! = ] J ) 84 ' ' ) > ' ) ! 'G

9 s 6- ) &' G ! 'G i! 'G #f j #V % &' Q 6P • " ) ' ) G ! 'G 6(n 6f % ) & > h I t & " # $ J8 6$ 9* S )

2Œ }„ , •lr

T& s " ' " 6~ p ^ F ) I J ) 84 $ )

e # ' _ % $ b 9* #V % ' b 6> % ) '& 6- ) E ' ! |! " ( ' ) #- ># ^ F ) J ) 84 (

k ^ F ) J ) 84 & ) * 9J ! Z &! ' ) $ ) > I )(R a )

e I t ^ F ) # % H b 2Œ }„ f •lrhy † • l‡

> h k J ) 84 $ ) ) ^ F ) J ) 84 eh J# 6(n I 6>• s ' " (* x

&' #- ! 'G \ ) CREATE PROFILE 6> M" " ) * & J ) 84 9J ) * & # % H

/" ! 'G 6> ' ) CREATE USER 8ALTER USER

s ) * & " J ) 84 ^ F ) \ ) " a ) ALTER SYSTEM I t & " ) $ > ' ) G # $ % &' E" J8 6~ p ! S ) c % 6- ) &

18.2.QU N LÝ PROFILE

18.2.1 T o Profile

&' ! 'G ( " ) * & J ) 84 ^ F ) ) = x CREATE PROFILE profile LIMIT

(196)

[CONNECT_TIME max_value] [IDLE_TIME max_value]

[LOGICAL_READS_PER_SESSION max_value] [LOGICAL_READS_PER_CALL max_value] [COMPOSITE_LIMIT max_value]

[PRIVATE_SGA max_bytes]

max_value :== {integer|UNLIMITED|DEFAULT} max_bytes :== {integer[K|M]|UNLIMITED|DEFAULT} r* x

profile tên c a profile

UNLIMITED xác nh user c gán profile t #ng ng có th s d ng khơng h n ch tài nguyên

DEFAULT m c profile h n ch s d ng tài nguyên c ch m nh ! t #ng ng thu c DEFAULT profile COMPOSITE_LIMIT

gi i h n s d ng tài nguyên t-ng c ng bao g m c tr&ng s t #ng ng Gi i h n c tính b.ng t-ng s : CPU_PER_SESSION, CONNECT_TIME,

LOGICAL_READS_PER_SESSION, PRIVATE_SGA z ‡œ

r Y RESOURCE_COST ' ) ' ' " y ) $ ( ) Z ) 6(n )" ' " J ) 84 % " „ ) > h ^ F ) ALTER RESOURCE COST 6h 6(n " y ) $ ' S ) J ) 84 % "

r+ Fx

CREATE PROFILE developer_prof LIMIT SESSIONS_PER_USER

CPU_PER_SESSION 10000 IDLE_TIME 60

CONNECT_TIME 480; $ &( Qk s t qz• k

E &8 ) E y < 'G š™E

' ) ! P / ! ) • ! 9J' 9J " ) Z ) 9* S ) #F J ) 84

QO# B 0!!

18.2.2 Thi t l p gi i h n v* ti nguyờn

ã m w ê r lr rl

$ ™ •

CPU_PER_SESSION ] ) (n ) R ) E<W• 6(n M" 6 ' 6 9 {# ) =8

SESSIONS_PER_USER .$ (n ) $ 6 " ' > h ^ F ) 6c ) R a )

#-CONNECT_TIME R ) % $ $ • + ' 6 9 ! B

IDLE_TIME R ) A• + ' 6 9 ! B

LOGICAL_READS_PER_SESSION .$ (n ) ' % 6(n 6y

PRIVATE_SGA ra ) % ) ) ) J 4 ) ' ) /0• + ' 6 9

(197)

ã m w ê kll lr rl

$ ™ •

CPU_PER_CALL R ) ^ F ) E<W ' #V P )y • + ' 6 9

{# ) =8

LOGICAL_READS_PER_CALL .$ (n ) ' % 6(n 6y $ 6 oœ

IDLE_TIME 6(n "! F ) t ' " / * & IDLE_TIME % ) ( ) )3 6$ 9* " = 9O J " ' " % "

LOGICAL_READS_PER_SESSION J ) * & " P 6y ' % S - * € ] 6g

PRIVATE_SGA"! F ) % &8 # i1 j

18.2.3 Gán Profile cho User

r )" ! 'G > h 6(n s ) ' ) CREATE USER ALTER USER r+ Fx ^ F ) CREATE USER 6h &' #- USER3 9* # % H J USER3• 6> )" ! 'G > JDEVELOPER_PROF ' 9S &'

CREATE USER user3 IDENTIFIED BY user3 DEFAULT TABLESPACE data01

TEMPORARY TABLESPACE temp QUOTA unlimited ON data01 PROFILE developer_prof;

e I t SCOTT 9J )" ! 'G DEVELOPER_PROF ' W J8 ALTER USER scott

PROFILE developer_prof; $ &( Qk š y l | r qz• k

E &8 )

E y < 'G š™0 ) < 'G '

' ) ! P ) < 'G ! ) • y ( ) Z ) QO# B

€ ‘ … n pk , •lr

< 'G 6(n )" % ) ( ) * ' R

< 'G t > h 6(n )" ' % ) 6(n )" ' ' ' " ! 'G % " ' ) (R ) n! % ) )" ! 'G ' ) S % #* &' • ! 'G #f i G ! 'G j ƒ 6(n s 6- ) )" ' 6>

18.2.4 :t gi i h n tài nguyên

> h 6f ) * & ^ F ) J ) 84 ) # $ % &'RESOURCE_LIMIT ^ F ) = ALTER SYSTEM

2Œ }„ k| ‘ x m %(2&8% (— ! !$

E ' ! |! 'f % ) ' ! |! "! F ) " ) * & J ) 84 r* " J8• P % 6- ) & % 6] " ) " ' ) G # $ % &'

/ " b # $ JTRUE ' ! |! ) * & J ) 84 X)(n & • ) " ƒ JFALSE i6=8 J ) " #f j

2Œ }„ lt ' $(% 2G2$(

(198)

E" I t ' ALTER SYSTEM ƒ > " F ) ) ' * % > #- I t % " 'f % _

^ F ) J8 ' ) (R ) n! # $ & ^ F ) J ) 84 #J & % ) 6(n _

18.2.5 Thay 5i thông tin profile

> h 6] " ) ' ) ! 'G ) = ALTER PROFILE EB ! "!x

ALTER PROFILE profile LIMIT

[SESSIONS_PER_USER max_value] [CPU_PER_SESSION max_value] [CPU_PER_CALL max_value] [CONNECT_TIME max_value] [IDLE_TIME max_value]

[LOGICAL_READS_PER_SESSION max_value] [LOGICAL_READS_PER_CALL max_value] [COMPOSITE_LIMIT max_value]

[PRIVATE_SGA max_bytes] r+ Fx

ALTER PROFILE default LIMIT SESSIONS_PER_USER CPU_PER_CALL 3600 IDLE_TIME 30;

$ &( Qk s t r qz• k E &8 )

E 8h * B < 'G E y ! 'G ( ) Z )

' ) ! P / ! ) 6] " ) $ ' ) S ) #F ; QO# B 0!!

18.2.6 Hu- profile

s U ! 'G ' DROP PROFILE EB ! "!x

DROP PROFILE profile [CASCADE]

r* x profile tên c a profile b hu$

CASCADE hu$ t t c profile ã c gán cho user r+ Fx

DROP PROFILE developer_prof; Ho c

DROP PROFILE developer_prof CASCADE; $ &( Qk s t r qz• k

(199)

18.2.7 Thông tin v* gi i h n tài nguyên

eh M # ) 9I " ) * & ^ F ) J ) 84 • M # M| ' ) " ' DBA_USERS9JDBA_PROFILE

T3 9ƒ d? ) 9I ) * & J ) 84

r+ Fx M # ) * & J ) 84 b W SCOTT

SVRMGR1> SELECT p.profile, p.resource_name, p.limit 2> FROM dba_users u, dba_profiles p

3> WHERE p.profile=u.profile AND username=’SCOTT’ AND 4> p.resource_type=’KERNEL’;

PROFILE RESOURCE_NAME LIMIT

- - - DEVELOPER_PROF COMPOSITE_LIMIT DEFAULT DEVELOPER_PROF SESSIONS_PER_USER

DEVELOPER_PROF CPU_PER_SESSION 10000

DEVELOPER_PROF CPU_PER_CALL DEFAULT

DEVELOPER_PROF LOGICAL_READS_PER_SESSION DEFAULT DEVELOPER_PROF LOGICAL_READS_PER_CALL DEFAULT

DEVELOPER_PROF IDLE_TIME 60

DEVELOPER_PROF CONNECT_TIME 480

DEVELOPER_PROF PRIVATE_SGA DEFAULT

9 rows selected

18.3.QU N LÝ M0T KH'U

eh > h # ' ' # ' 'J - • $ ) k # % H ' ! |! k # % H ) " ! 'G r k # % H J8 > #- $ 6f h# x

0 ' ' % )x ' ! |! s 6- ) % '" ' ( ) Z ) 9* #V % 6> % ) h % $ * $ )

/_ R & ^ F ) ' #V # % H x #V # % H ƒ > #- R & ^ F ) O • 5" R & • # % H P 6(n 6]

:( ^ 6] # % H i< Y' ' 8jx % h# " # % H #* 6h # ' # % H #* % ) a ) 9* " # % H (* 6>

E M" # % H #I# ‚'x ' ! |! % h# 9J M" # % H #- " #I# ‚' ( ) 9€ # ' + f ƒ $ ) & 6(n ) Z $ M=#

(200)

T3 9ƒ dD k # % H

E„ ) ( ) s ( 6( " ) * & 9I J ) 84 ^ F )• „ ) > h ^ F ) " ! 'G 6h ! " ) * & 9I # % H 9J )" ' #V ) CREATE ALTER USER

s k # % H • > h ^ F ) " = CREATE USER 8ALTER USER 6h ' % ' % ' b 6>

18.3.1 T o profile qu n lý m t kh)u

&' ! 'G k # % H ) CREATE PROFILE EB ! "!x

CREATE PROFILE profile LIMIT

[FAILED_LOGIN_ATTEMPTS max_value] [PASSWORD_LIFE_TIME max_value] [ {PASSWORD_REUSE_TIME

|PASSWORD_REUSE_MAX} max_value] [ACCOUNT_LOCK_TIME max_value] [PASSWORD_GRACE_TIME max_value] [PASSWORD_VERIFY_FUNCTION

{function|NULL|DEFAULT} ] r+ Fx

CREATE PROFILE grace_5 LIMIT FAILED_LOGIN_ATTEMPTS PASSWORD_LIFE_TIME 30 PASSWORD_REUSE_TIME 30

PASSWORD_VERIFY_FUNCTION verify_function PASSWORD_GRACE_TIME 5;

' ) C1• s ' " (* x E &8 )

E y < 'G š™E

' ) ! P < Y' < '! ! 9J' " # $ # % H b ' QO# B 0!!

18.3.2 Các tham s i*u chDnh m t kh)u

$ ™ •

FAILED_LOGIN_ATTEMPTS .$ P % $ p ) i ' ! 4 8 # % H j $ 6

PASSWORD_LOCK_TIME .$ )J8 ' % ' b %h S % & ^ F )

Ngày đăng: 21/04/2021, 20:29

w