Unit 1 (dba)

Embed Size (px)

Citation preview

  • 8/12/2019 Unit 1 (dba)

    1/23

    INTRODUCTION TO ORACLE DATABASE

    1

  • 8/12/2019 Unit 1 (dba)

    2/23

    INTRODUCTION TO ORACLE DATABASE

    Objectives

    At the end of this unit, you will be able to

    Lea!n about O!a"le a!"hite"tu!e in b!ief

    Topics

    Int!odu"tion to O!a"le#

    Lo$i"al database st!u"tu!e

    %hysi"al database st!u"tu!e

    Se!&e! a!"hite"tu!e

    '

  • 8/12/2019 Unit 1 (dba)

    3/23

    INTRODUCTION TO ORACLE DATABASE

    ORACLE DATABASE ARCHITECTURE

    INTRODUCTION

    An O!a"le database is a "olle"tion of data that is t!eated as a unit# The $ene!al (u!(ose ofa database is to sto!e and !et!ie&e !elated info!)ation# The database has a lo$i"al

    st!u"tu!e and a (hysi"al st!u"tu!e#

    The (hysi"al st!u"tu!e of the database is the set of o(e!atin$ syste) files in the database#

    An O!a"le database "onsists of th!ee file ty(es

    Data files * "ontain the a"tual data in the database# The data is sto!ed in use!*

    defined tables, but data files also "ontain the data di"tiona!y, befo!e*i)a$es of)odified data, inde+es, and othe! ty(es of st!u"tu!es# A database has at least one data

    file# The "ha!a"te!isti"s of data files a!e

    A data file "an be asso"iated with only one database#

    Data files "an ha&e "e!tain "ha!a"te!isti"s set to allow the) to auto)ati"ally

    e+tend when the database !uns out of s(a"e#

    One o! )o!e data files fo!) a lo$i"al unit of database sto!a$e "alled a tables(a"e#

    Redo Log Files * Redo lo$s "ontain a !e"o!d of "han$es )ade to the database to

    enable !e"o&e!y of the data in "ase of failu!es# The !edo lo$s a!e "!eated in $!ou(s#

    An O!a"le database )ust ha&e at least two !edo lo$ $!ou(s# The !edo lo$ )e)be!s

    a!e the a"tual datafiles# hen a $!ou( has )o!e than one )e)be!, the !edo lo$s a!e"onside!ed )ulti(le+ed# A )ulti(le+ed !edo lo$ $!ou( w!ites to ea"h )e)be! at the

    sa)e ti)e# This (!o&ides a way of )i!!o!in$ the !edo lo$s, and O!a"le st!on$ly

    !e"o))ends this (!o"edu!e# -ou should (la"e the $!ou( )e)be!s on diffe!ent dis.de&i"es and dis. "ont!olle!s to (!e&ent (!oble)s f!o) o""u!!in$ due to dis. o!

    "ont!olle! failu!e# On"e a $!ou( has a )e)be!, all subse/uent new )e)be!s )ust be

    the sa)e si0e# o! (e!fo!)an"e !easons, you )i$ht add !edo lo$ $!ou(s due to hi$h

    le&els of t!ansa"tion a"ti&ity#

    Te Co!t"ol File # Cont!ol files "ontain info!)ation ne"essa!y to )aintain and &e!ify

    database inte$!ity# o! e+a)(le, a "ont!ol file is used to identify the data files and

    !edo lo$ files# A database needs at least one "ont!ol file# The "ont!ol file is a s)allbina!y file !e/ui!ed to )ount and o(en an O!a"le database# The instan"e )ust be able

    to w!ite to this file when the database is o(en# The# database na)e and the lo"ation of

    all e+te!nal files 2database files and !edo lo$s3 asso"iated with an instan"e a!e"ontained in the "ont!ol file# hen !e"o&e!in$ a database, you use the "ont!ol file to

    dete!)ine whi"h datafiles )ust be !e"o&e!ed #The "ont!ol file na)e is s(e"ified in the4

  • 8/12/2019 Unit 1 (dba)

    4/23

    INTRODUCTION TO ORACLE DATABASE

    init#o!a file with the Cont!ol5files (a!a)ete!# O!a"le !e"o))ends that you define at

    least th!ee "ont!ol files fo! one instan"e#

    Ote" $e% Files

    The O!a"le se!&e! also uses othe! files that a!e not (a!t of the database

    The (a!a)ete! file defines the "ha!a"te!isti"s of an O!a"le instan"e# o! e+a)(le, it"ontains (a!a)ete!s that si0e so)e of the )e)o!y st!u"tu!es in the S6A#

    The (asswo!d file authenti"ates whi"h use!s a!e (e!)itted to sta!t u( and shut down an

    O!a"le instan"e#

    A!"hi&ed !edo lo$ files a!e offline "o(ies of the !edo lo$ files that )ay be ne"essa!y to!e"o&e! f!o) )edia failu!es#

    The Lo$i"al St!u"tu!e * O!a"le allo"ates lo$i"al database s(a"e fo! all data in a database#The units of database space allocation are

    Tablespaces

    Segments

    ExtentsData Blocks

    At the finest le&el of $!anula!ity, O!a"le sto!es data in data blo".s 2also "alled lo$i"al

    blo".s, O!a"le blo".s, o! (a$es3# One data blo". "o!!es(onds to a s(e"ifi" nu)be! of

    bytes of (hysi"al database s(a"e on dis. The ne+t le&el of lo$i"al database s(a"e is "alledan e+tent# An e+tent is a s(e"ifi" nu)be! of "onti$uous data blo".s allo"ated fo! sto!in$ a

    s(e"ifi" ty(e of info!)ation #The le&el of lo$i"al database sto!a$e abo&e an e+tent is"alled a se$)ent# A se$)ent is a set of e+tents that ha&e been allo"ated fo! a s(e"ifi" ty(eof data st!u"tu!e# o! e+a)(le, ea"h table7s data is sto!ed in its own data se$)ent, while

    ea"h inde+7s data is sto!ed in its own inde+ se$)ent# If the table o! inde+ is (a!titioned,

    ea"h (a!tition is sto!ed in its own se$)ent# O!a"le allo"ates s(a"e fo! se$)ents in units ofone e+tent# hen the e+istin$ e+tents of a se$)ent a!e full, O!a"le allo"ates anothe!

    e+tent fo! that se$)ent# Be"ause e+tents a!e allo"ated as needed, the e+tents of a se$)ent

    )ay o! )ay not be "onti$uous on dis.#A se$)ent 2and all its e+tents3 a!e sto!ed in one

    tables(a"e# ithin a tables(a"e, a se$)ent "an s(an datafiles 2ha&e e+tents with dataf!o) )o!e than one file3# 8owe&e!, ea"h e+tent "an "ontain data f!o) only one datafile#

    Data Bloc&sO!a"le )ana$es the sto!a$e s(a"e in the datafiles of a database in units "alled data blo".s#

    A data blo". is the s)allest unit of I9O used by a database# In "ont!ast, at the (hysi"al,

    o(e!atin$ syste) le&el, all data is sto!ed in bytes# Ea"h o(e!atin$ syste) has what is"alled a blo". si0e# O!a"le !e/uests data in )ulti(les of O!a"le data blo".s, not o(e!atin$

    syste) blo".s #-ou set the data blo". si0e fo! ea"h O!a"le database when you "!eate the

    database #This data blo". si0e should be a )ulti(le of the o(e!atin$ syste)7s blo". si0ewithin the )a+i)u) li)it to a&oid unne"essa!y I9O# O!a"le data blo".s a!e the s)allest

    units of sto!a$e that O!a"le "an use o! allo"ate#

    :

  • 8/12/2019 Unit 1 (dba)

    5/23

    INTRODUCTION TO ORACLE DATABASE

    Data Blo". St!u"tu!e *

    Data Bloc& Fo"'at

    The O!a"le data blo". fo!)at is si)ila! !e$a!dless of whethe! the data blo". "ontainstable, inde+, o! "luste!ed data#

    Heade" (Co''o! a!d )a"iable*

    The heade! "ontains $ene!al blo". info!)ation, su"h as the blo". add!ess and the ty(e of

    se$)ent 2fo! e+a)(le, data, inde+, o! !ollba".3#

    Table Di"ecto"%

    This (o!tion of the data blo". "ontains info!)ation about the tables ha&in$ !ows in this

    blo".#

    Ro+ Di"ecto"%

    This (o!tion of the data blo". "ontains info!)ation about the a"tual !ows in the blo".

    2in"ludin$ add!esses fo! ea"h !ow (ie"e in the !ow data a!ea3# On"e the s(a"e has beenallo"ated in the !ow di!e"to!y of a data blo".7s o&e!head, this s(a"e is not !e"lai)ed

    when the !ow is deleted# The!efo!e, a blo". that is "u!!ently e)(ty but had u( to ;< !ows

    at one ti)e "ontinues to ha&e 1

  • 8/12/2019 Unit 1 (dba)

    6/23

    INTRODUCTION TO ORACLE DATABASE

    Ro+ Data

    This (o!tion of the data blo". "ontains table o! inde+ data#

    F"ee Space

    !ee s(a"e is allo"ated fo! inse!tion of new !ows and fo! u(dates to !ows that !e/ui!e

    additional s(a"e 2fo! e+a)(le, when a t!ailin$ null is u(dated to a non*null &alue3#hethe! issued inse!tions a"tually o""u! in a $i&en data blo". is a fun"tion of "u!!ent f!ee

    s(a"e in that data blo". and the &alue of the s(a"e )ana$e)ent (a!a)ete! %CTREE#

    A! I!t"od,ctio! to -CTFREE. -CTUSED

    Two s(a"e )ana$e)ent (a!a)ete!s, %CTREE and %CTUSED, enable you to "ont!ol the

    use of f!ee s(a"e fo! inse!ts of and u(dates to the !ows in all the data blo".s of a

    (a!ti"ula! se$)ent# -ou s(e"ify these (a!a)ete!s when "!eatin$ o! alte!in$ a table o!"luste! 2whi"h has its own data se$)ent3#

    Te -CTFREE -a"a'ete"

    The %CTREE (a!a)ete! sets the )ini)u) (e!"enta$e of a data blo". to be !ese!&ed asf!ee s(a"e fo! (ossible u(dates to !ows that al!eady e+ist in that blo".# o! e+a)(le,

    assu)e that you s(e"ify the followin$ (a!a)ete! within a CREATE TABLE state)ent

    %CTREE '