Oracle Architecture

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 6

Oracle Architecture:

--------------------------
* Here we will study
- How oracl internal file structure is arranged
- How the data file arranged
- How the tablespaces are arranged
- How instances the arranged

oracle has following database layer


-----------------------------------------------------------------------------
1) physical DB layer( physical representation of the oracle file system)
2) Logical DB layer
3) Instance architecture

1. physical DB layer
--------------------
*Contains the physical representation of the oracle file system
Example:
insert into table values...
commit;
*tables are stored as FILES

Types of file:
--------------
1) Data file
*Permantly stores the data in file system(DB).
*Whenever we {SELECT} data from table , the file is fetched from datafile.
*The data in the datafile is not over written. I.E if the datafile is filled com
pletly then the upcoming data is written to next datafile.
*Minimum one datafile is required DB.
2) Redo logs or Redo log files
* Redolog file work on sequentional manner i.e One after the after (fills ,overw
rite).
* Redolog file data is not permanet.
* Redo log files contains the duplicate copy of data file.
* It is used for backup and restoration purpose [DBA will do this].
* Minimum two Redo log files are required in DB.
* Switching between Redolog file is called Log switch.
Note:
1. When we create database objects or insert or update or delete , they are stor
ed in datafile and same copy is stored in Redo log files.
2. In case of datafile crash, we can back up the datafile using Redolog file.
3. If Redolog file crashes, then we can backup the Redolog file using ARCHIVELOG
file.
3) Control file:
* Is like heart of the database
* It contains the names and location of the Redolog files and Datafile.
* Minimum one control file is required.
* It is smallest file.
Note:
1. Between datafile and Redolog file, datafile is biggest because it keeps on
growing.
2. Redolog file size will be of constant size.
4) Parameter file
* It is like a configuration file.
* Contains the all the parameters for a database to configure.
Example: nls_date_format , open_cursors , user_dump_dest ,name of the control fi
le, how number of session,global database name
Note:
* When DB starts up
--> first it opens parameter file and loaded. memorizes all the settings and co
nfigures the database.Parameter file is also called as init.ora
--> Next, it opens the controle file. Then it opens the datafile and redolog f
ile.
--> After opening datafile and redolog file only we will get SQL promt.
---------------------------------------------------------
Size of DB= Size of DF + Size of RF + Size of CF
---------------------------------------------------------
Note: We never consider Parameter file in Database size.

2) Logical DB layer
* Logical divisioning layer was done for better management of DB.
* In logical DB layer
Many Block----> Many Extent----> Many segments will form ---> One tablespa
ce and many table spaces will form ---->A Databse
1. Database Block
------------------------
* Is finest unit of the data storage.
* A datafile contains many database blocks.
* The default size of block is 8KB.
2. Extents
* Is a contineous set of DB blocks.
* 1 Extents = 8 blocks
* We always allocate size of table in terms of table
Eaxmple: The table should have contains Only 1 MB of data. So how many extents t
o be created?
=>
1 block = 8KB
1 Extent = 8 Blocks
1 Extent= 8*8 =64 bytes.
1MB of data to be stored in table requires= 16 Extent ( 1024/64)
3. Segment.
* Is collection of one or more Extent.
* A segement is created by default whenever we create a table or index.
Suppose i have 10 tables and 10 indexes , the we will have 20 segments.
Types:
1. data segment.
* stores the table
2. Index Segment
* stores the Index
3. Undo segment
* stores the data to be rollbacked.
4. Temporvary Segment
* stores the temporvary data like sorting
* While sorting, order by , the temporvary segment is used as storage
4.TableSpace
* Is a logical container that can store one or more data file.
* A tablespace can contains more than one segment[Tables + Indexces]
* If we do not mention tablespace name, the table and index will use default tab
lespace[The default tablespace is USERS[ select tablespace_name from user_tables
;] ]
* Tablespace is like a folder in a computer.
* A tablespace will helps to seggregate the data like all table in 1st TS1 , all
indexes in 2nd TS2 for better perfomance
How tablespace is created? [DBA]
--------------------------------------
Create a tablespace named OracleForBeginners connected to a data file with a siz
e of 50MB.
create tablespace OracleForBeginners
datafile 'datatest.dat' -- data file name
size 50M -- size of tablespace
autoextend on -- If available space(In this case above mentioned size 50MB ,i u
sed up, it runs out of space. autoextend on is used to specify that the table s
hould grow dynamically).
next 10m -- Here, the tablespace auto extends in increments of 10MB until it re
aches maximum 100MB maxsize 100m
online; -- Makes the tablespace available immediately after creation to users w
ho have been granted access to the tablespace.
How to place table inside a table space?
-------------------------------------------
create table test11(
id number,
name varchar2(20)
) tablespace OracleForBeginners;

How to check on which tablespace my table is sits?


-------------------------------------------------------
select TABLESPACE_NAME
from all_tables -- or user_tables
where TABLE_NAME ='TEST11'

Types of tablespace
----------------------
By default below 5 tablespaces are created when database is created.
1. SYSTEM tablespace
* is created when Database is created.
* it is always online
* it stores the data dictionary
Example: user_tables,all_tables,user_views,user_triggers, user_source Etc.
Note: All user tables i.e emp, dept etc are stored in USERS tabalespace.
2. SYSAUX
* It is auxilary tablespace i.e is additional tablespace that stores the load of
SYSTEM table
* It is introduced from 10g
3. TEMP
* It stores the temporary data like sorting
4. UNDO
* It stores the data that can be rollbacked.
* It contains user objects like table,view indexes

3) Instance architecture
------------------------------
- Here study How internally oracle works
- How datafile,control file, redolog file interacted
- How SGA works
Instance :
----------
- An instance is process to access the DB server.
- An instance is combination of Background processes and Memory[RAM]
Memory Architecture:
-------------------------
- Oracle's memory contains SYSTEM/SHARED GLOBAL AREA (SGA) and Program/private G
lobal Area (PGA).
SGA:
-----
- is shared memory across the server.
- it will be one per server.
- all sessions (scott/tiger) will have common shared memory.
- the SGA size is given init.ora
Components of SGA:
----------------------
1. Dictionary Cache
2. Library Cache
3. Database Buffer cache
4. Redo Log buffer cache
Note: The combination of 1 and 2 is called shared pool.
------
1. Dictionary Cache
- It stores the recently used recursively SQL statements( statements Executed on
data dictionary).
2. Library Cache
- It stores recently executed SQL statements and PLSQL statements executed by us
er.
3. Database Buffer cache
- It stores the recently query data and modified data
4. Redo Log buffer cache
- It store the recently modified data.

Background processes :
---------------------------
- The Background processes act like interface between the DB and Memory
- There are 5 mandatory background process.
1. PMON-process monitor
- It perform session cleanup and auto rollback during abnormal exit.
2. SMON - system monitor
- It perofm instance recovery(IR).
- Instance recovery is nothing but synchronization between redolog file (RF)to d
atafile(DF).
- Synchronization will be done by SMON during database startup. It uses for SCN
for IR.
- IR is required only if the database has been shutdown abnormally in the previo
us occasion.
- SCN is unique number, that get generated for every commit.

3. CKPT- Check Point


- check point is event during which all the data from DBbuffer cache are written
to datafiles and from Redolog buffer files written to Redolog file.
- check point automatically happens by oracle.
4. DBWR- Database Writer
- It writes the data from DBbuffer cache are written to datafile during check p
oint or Commit;
5. LGWR- Log writer
- It writes the data from redo log buffer to Redolog file.

Explain oracle architecture?


------------------------------
- Oracle Architecture consists of Oracle Server. That literally contains a datab
ase and instance.
- Instance means combination of SGA+ Background process.

You might also like