4
Data Files Data Dictionary META (Users, Schema, Storage) Data Structures Access Structures Procedural Objects Redo Log Files (min 2) i.e. Exception Handling Journal File (Recovery/UNDO) DB changes (DB, Table, Users) (SYS will archive Redo) Archives used for reviews for Tuning & Capacity planning. Control Files (min 2) When DB created (Name & identifier) File names (data/redo) Last DB checkpoint – Ref Timestamps + Redos Changes to DB Backup Info Log History Tablespace Names Hardware Architecture: Physical Structure Hardware Architecture: Logical Structure contains: Redo Log Files & Control Files. Number of tablespaces (1-255 OS files each plus storage space to impose structure) Objects allocated to 1 tablespace only. System Tablespace Created when DB installed via CREATE DATABASE Inc. Data Dictionary Inc. System Rollback Segment Tablespace A Based on size Tablespace B Based on size Space Administration Space Allocation to user CREATE DATABASE EXAMPLE: CONTROLFILE REUSE LOGFILE ‘REDO1.LOG’ SIZE 30MB, ‘REDO1.LOG’ SIZE 30MB, DATAFILE ‘FILE1.ORA’ 250MB; CREATE TABLESPACE TA DATAFILE ‘FILE1.ORA’ 250MB, DATAFILE ‘FILE2.ORA’ 250MB; CREATE TABLESPACE TB DATAFILE ‘FILE3.ORA’ 250MB, DATAFILE ‘FILE4.ORA’ 250MB; + Commands: DROP TABLESPACE TA i.e. only if empty – unless INCLUDING CONTENTS (privilege reqd.) RE-SIZE, READ-ONLY, OFFLINE OFFLINE via: ALTER TABLESPACE TA (Default NORMAL, IMMEDIATE, TEMPORARY) NORMAL - “checkpoint” executed (all T/space files) – all data in DB flushed to Disk. IMMEDIATE – no “checkpoint” & offline. Recovery required when back online. TEMPORARY – “checkpoint” for online T/space files – offline as in IMMEDIATE. Advantages of Tablespaces: If hardware error – only 1 tablespace affected. Efficiency improvement. TABLESPACE >> Segments >> Extents >> Oracle Data Blocks. Parameter File Archived Log File Password File DB Instance Defaults DB Resources Control Files/Archived Log Tablespace Types: TEMP for Sorting (No PERM OBJS) READ-ONLY inc OBJS can be dropped

Data Files Data Dictionary META (Users, Schema, Storage) Data Structures Access Structures

  • Upload
    chika

  • View
    23

  • Download
    0

Embed Size (px)

DESCRIPTION

Hardware Architecture: Physical Structure. Parameter File. Data Files Data Dictionary META (Users, Schema, Storage) Data Structures Access Structures Procedural Objects. Redo Log Files (min 2) i.e. Exception Handling Journal File (Recovery/UNDO) - PowerPoint PPT Presentation

Citation preview

Page 1: Data Files   Data Dictionary META (Users, Schema, Storage)   Data Structures   Access Structures

Data Files• Data Dictionary META(Users, Schema, Storage)• Data Structures• Access Structures• Procedural Objects

Redo Log Files (min 2)i.e. Exception Handling• Journal File (Recovery/UNDO)• DB changes (DB, Table, Users)(SYS will archive Redo)• Archives used for reviews for Tuning & Capacity planning.

Control Files (min 2)• When DB created(Name & identifier)• File names (data/redo)• Last DB checkpoint – Ref Timestamps + Redos• Changes to DB• Backup Info• Log History• Tablespace Names

Hardware Architecture: Physical Structure

Hardware Architecture: Logical Structure contains:• Redo Log Files & Control Files.• Number of tablespaces (1-255 OS files each plus storage space to impose structure)• Objects allocated to 1 tablespace only.

System Tablespace• Created when DB installed• via CREATE DATABASE• Inc. Data Dictionary• Inc. System Rollback Segment

Tablespace A• Based on size Tablespace B

• Based on size• Space Administration• Space Allocation to user

CREATE DATABASE EXAMPLE:

CONTROLFILE REUSELOGFILE ‘REDO1.LOG’ SIZE 30MB,‘REDO1.LOG’ SIZE 30MB,DATAFILE ‘FILE1.ORA’ 250MB;

CREATE TABLESPACE TADATAFILE ‘FILE1.ORA’ 250MB,DATAFILE ‘FILE2.ORA’ 250MB;

CREATE TABLESPACE TBDATAFILE ‘FILE3.ORA’ 250MB,DATAFILE ‘FILE4.ORA’ 250MB;

+

Commands:DROP TABLESPACE TA i.e. only if empty – unless INCLUDING CONTENTS (privilege reqd.)RE-SIZE, READ-ONLY, OFFLINE

OFFLINE via:ALTER TABLESPACE TA (Default NORMAL, IMMEDIATE, TEMPORARY)

• NORMAL - “checkpoint” executed (all T/space files) – all data in DB flushed to Disk.• IMMEDIATE – no “checkpoint” & offline. Recovery required when back online.• TEMPORARY – “checkpoint” for online T/space files – offline as in IMMEDIATE.

Advantages of Tablespaces:• If hardware error – only 1 tablespace affected.• Efficiency improvement.

TABLESPACE >> Segments >> Extents >> Oracle Data Blocks.

ParameterFile

Archived LogFile

PasswordFile

• DB Instance Defaults• DB Resources• Control Files/Archived Log

Tablespace Types:• TEMP for Sorting (No PERM OBJS)• READ-ONLY inc OBJS can be dropped

Page 2: Data Files   Data Dictionary META (Users, Schema, Storage)   Data Structures   Access Structures

Database

Logical Physical

Tablespace Data file

OS blockOracle block

Segment

Extent

Database Storage Hierarchy

Page 3: Data Files   Data Dictionary META (Users, Schema, Storage)   Data Structures   Access Structures

TABLESPACE Structure

4 Objects:-• Data Segments• Index Segments• Rollback Segments(Transaction Rollback & Recovery)• Temporary Segments (pre-COMMIT)• Nested TablesSegment creation location depends onAllocation of Tablspaces to user.

CREATE USER DGEO IDENTIFIED BY PASSWORD XCDEFAULT TABLESPACE TATEMPORARY TABLESPACE TAQUOTA UNLIMITED ON TAQUOTA 10MB ON TB;

Segment Creation:

STORAGE ( INITIAL 20MB,NEXT 10MB,

MINEXTENTS 3,MAXEXTENTS 3,

PCTINCREASE 15,FREELISTS 3)

SEGMENT Structure

• To minimise fragmentation.• Allocation of storage space.• “NEXT” segments allocated by System when available space insufficient.• PCTINCREASE = growth factor for each subsequent “NEXT” over previous.• EXTENTS allocated when SEG created/extended/altered.• De-allocated when SEG dropped/altered.

DATA BLOCK Structure = Min units of I/O

Data Block Header –includes Row & Trans Directory

PCTFREE “Free Area”

Data Block “Insert Area”

Minimum Block Space

PCTUSED

Segment Data Blocks defined via:• PCTFREE i.e. kept free, when records inserted, for future trans.• PCTUSED i.e. % of data block space to be used before new D/Block.• INITRANS/MAXTRANS i.e. maximum transactions per Data Block

NB:• Insert Area = new records. Free Area = growth for existing records. Key issue for VARCHAR & VARCHAR2 i.e. have variable lengths e.g “Smith” >> “Arrowsmith” on name change. Thus if data block too small – placed in “Free”.• Where “Free” too small – whole record >> new D/Block and chain-linked to avoid index updating.• PCTFREE should be 50-60% if file volatile.• PCTUSED important to optimise space created by PCTFREE or deletions.• If no free D/Blocks system creates “NEXT” Extent.

Page 4: Data Files   Data Dictionary META (Users, Schema, Storage)   Data Structures   Access Structures

RECORD Format

Record has 2 components: Row Header & Row Body.

Col length Column data Col length  etc

Rowheader

Row Body i.e. containing columns – each column has its own header stating its column length

Record Header

No of columns

Cluster index

Chain link

Calculating Table Rows that can be stored in a Data Block:

• Block Space minus block header and PCTFREE• Block Space remaining / Table Row size = No of Table Rows stored.