Top Banner
Oracle Database Oracle Database Workshop 1 Workshop 1 Presented to IBRI CAS Presented to IBRI CAS 27-Nov-2011 27-Nov-2011 By Abdullah Alkalbani By Abdullah Alkalbani
71

Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Dec 26, 2015

Download

Documents

Madlyn Jones
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Oracle DatabaseOracle DatabaseWorkshop 1Workshop 1

Presented to IBRI CASPresented to IBRI CAS27-Nov-201127-Nov-2011

By Abdullah AlkalbaniBy Abdullah Alkalbani

Page 2: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Workshop ObjectivesWorkshop Objectives

• Describe Oracle Database (10g).• Identify high-level architectural components

of an Oracle Database.• Identify Oracle Database internal data

structures.• Define the mechanisms used when

processing Insert/Update/Delete statements.• Describe DBMS programs used with Oracle

Database.

Page 3: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

10g provides better ways to administer your database. “It takes the mountain out of the mole hill”.

Page 4: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

• 9i Mountains = More effort and resources to accomplish similar tasks in 10g

• 10g Mole Hills = Less effort and resources to accomplish similar tasks in 9i.

Page 5: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Popular FeaturesPopular Features

•Automatic Shared Memory Management (ASMM)

•Data Pump•SQL Tuning Advisor•Flashback Database

•RMAN - Backupset Compression

Page 6: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Most people call it a “Database”Most people call it a “Database”

Technically an Oracle Database is broken into two high-level components

1. INSTANCE – Non-persistent, memory-based processes and structures

2. DATABASE – Persistent, disk-based data and control files

Page 7: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

So Why Differentiate?So Why Differentiate?

Most Oracle installations consist of only a single “Instance” and single “Database”…

Instance

Database

Page 8: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Oracle RAC is DifferentOracle RAC is Different

Oracle “Real Application Clusters” allow multiple “Instances” to interact with a single “Database” to provide high availability…

Instance 1

Database

Instance 3Instance 2

Page 9: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

““Instance” a Little CloserInstance” a Little Closer

An Oracle Instance…– Is a means to access an Oracle Database– Always opens one and only one Database– Consists of memory and background process

structures

Page 10: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Picture of an “Instance”Picture of an “Instance”Instance

LibraryCache

DataDictionary

Cache

Shared PoolSGA

Database BufferCache

Redo LogBuffer

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

MemoryStructures

Back-GroundProcesses

Page 11: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

““Database” a Little CloserDatabase” a Little Closer

An Oracle Database…– Is a collection of data that is treated as a unit– Consists of three file types

Page 12: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Picture of a “Database”Picture of a “Database”

ArchivedLog Files

ParameterFile

PasswordFile

Oracle Database

Data Files Control Files Redo Log Files

Page 13: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Picture of an “Instance”Picture of an “Instance”Instance

LibraryCache

DataDictionary

Cache

Shared PoolSGA

Database BufferCache

Redo LogBuffer

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

MemoryStructures

Back-GroundProcesses

Page 14: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Memory StructureMemory Structure

Oracle’s memory structure consists of two memory areas known as:

1. System Global Area (SGA): Allocated at instance start up, and is a fundamental component of an Oracle Instance

2. Program Global Area (PGA): Allocated when the server process is started

Page 15: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

System Global AreaSystem Global Area

• The SGA consists of several memory structures:– Shared Pool– Database Buffer Cache– Redo Log Buffer– Other structures

• There are two additional memory structures that can be configured within the SGA:– Large Pool– Java Pool

Page 16: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

System Global AreaSystem Global Area

• The size of the SGA is determined by the parameters that set the sizes of the various pools; these parameters are dynamic

• The SGA_MAX_SIZE parameter sets the maximum size of the SGA (so you can limit it) and is not a dynamic parameter

Thanks Ned!

Page 17: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Picture of an “Instance”Picture of an “Instance”Instance

LibraryCache

DataDictionary

Cache

Shared PoolSGA

Database BufferCache

Redo LogBuffer

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

MemoryStructures

Back-GroundProcesses

Page 18: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Shared PoolShared Pool

• Used to store:– Most recently executed SQL statements– Most recently used data definitions

• It consists of two key performance-related memory structures:– Library Cache– Data Dictionary Cache

• Sized by the parameter SHARED_POOL_SIZE

Page 19: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Library CacheLibrary Cache

• Stores information about the most recently used SQL and PL/SQL statements

• Enables the sharing of commonly used statements

• Is managed by a least recently used (LRU) algorithm

• Consists of two structures– Shared SQL area– Shared PL/SQL area

• Size is determined by the Shared Pool sizing

Page 20: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Picture of an “Instance”Picture of an “Instance”Instance

LibraryCache

DataDictionary

Cache

Shared PoolSGA

Database BufferCache

Redo LogBuffer

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

MemoryStructures

Back-GroundProcesses

Page 21: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Data Dictionary CacheData Dictionary Cache

• A collection of the most recently used definitions in the database

• Includes information about database files, tables, indexes, columns, users, privileges, and other database objects

• During the parse phase, the server process looks at the data dictionary for information to resolve object names and validate access

Page 22: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Database Buffer CacheDatabase Buffer Cache

• Stores copies of data blocks that have been retrieved from the data files

• Enables great performance gains when you obtain and update data

• Managed through an LRU algorithm

• DB_BLOCK_SIZE determines primary block size

Page 23: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Picture of an “Instance”Picture of an “Instance”Instance

LibraryCache

DataDictionary

Cache

Shared PoolSGA

Database BufferCache

Redo LogBuffer

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

MemoryStructures

Back-GroundProcesses

Page 24: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Redo Log BufferRedo Log Buffer

• Records all changes made to the database data blocks

• Primary purpose is recovery

• Changes recorded within are called redo entries

• Redo entries contain information to reconstruct or redo changes

• Size defined by LOG_BUFFER

Page 25: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Large PoolLarge Pool

• An optional area of memory in the SGA• Relieves the burden place on the Shared Pool• Used for:

– Session memory for the Shared Server– I/O server processes– Backup and restore operations for RMAN

• Does not use an LRU list• Sized by LARGE_POOL_SIZE• Can be dynamically resized

Page 26: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Java PoolJava Pool

• Services parsing requirements for Java commands

• Required if installing and using Java

• Sized by JAVA_POOL_SIZE parameter

Page 27: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Oracle “Process” StructureOracle “Process” Structure

• Oracle takes advantage of various types of Processes:– User Process: Started at the time a database

user requests connection to the Oracle Server– Server Process: Connects to the Oracle

instance and is started when a user establishes a session

– Background Processes: Started when an Oracle instance is started

Page 28: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

User ProcessUser Process

• A program that requests interaction with the Oracle server

• Must first establish a connection• Does not interact directly with the Oracle server

ServerProcess

UserProcess

ConnectionEstablished

Page 29: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Server ProcessServer Process

• A program that directly interacts with the Oracle server

• Fulfills calls generated and returns results

• Can be dedicated or shared server

Page 30: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Picture of an “Instance”Picture of an “Instance”Instance

LibraryCache

DataDictionary

Cache

Shared PoolSGA

Database BufferCache

Redo LogBuffer

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

MemoryStructures

Back-GroundProcesses

Page 31: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Background ProcessesBackground Processes

• Maintains and enforces relationships between physical and memory structures– Mandatory background processes:

DBWn PMON CKPTLGWR SMON

– Optional background processes:ARCn LMDn QMNnCJQ0 LMON RECODnnn LMS SnnnLCKn Pnnn

Page 32: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Database Writer (DBWn)Database Writer (DBWn)

DBWn writes when:• Checkpoint occurs

• Dirty buffers reach threshold

• There are no free buffers

• Timeout occurs

• Tablespace OFFLINE

• Tablespace READ ONLY

• Table DROP or TRUNCATE

• Tablespace BEGIN BACKUP

Oracle DatabaseData Files Control Files Redo Log Files

Instance

Shared Pool

LibraryCache

DataDictionary

Cache

SGA

Database BufferCache

Redo LogBuffer

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

Shared Pool

Page 33: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Log Writer (LGWR)Log Writer (LGWR)

LGWR writes:• At commit

• When one-third full

• When there is 1 MB of redo

• Every three seconds

• Before DBWn writes

Instance

Shared Pool

LibraryCache

DataDictionary

Cache

SGA

Database BufferCache

Redo LogBuffer

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

Oracle DatabaseData Files Control Files Redo Log Files

Page 34: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

System Monitor (SMON)System Monitor (SMON)

Responsibilities:• Instance recovery

– Rolls forward changes in online redo log files

– Opens database for user access

– Rolls back uncommitted transactions

• Coalesces free space

• Deallocates temporary segments

Oracle DatabaseData Files Control Files Redo Log Files

Instance

Shared Pool

LibraryCache

DataDictionary

Cache

SGA

Database BufferCache

Redo LogBuffer

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

Shared Pool

Page 35: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Process Monitor (PMON)Process Monitor (PMON)

Cleans up after failed processes by:

• Rolling back the transaction

• Releasing locks

• Releasing other resources

• Restarting dead dispactchers

Database BufferCache

Oracle DatabaseData Files Control Files Redo Log Files

Instance

Shared Pool

LibraryCache

DataDictionary

Cache

SGA

Redo LogBuffer

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

Shared Pool

Page 36: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Checkpoint (CKPT)Checkpoint (CKPT)

Responsible for:• Signaling DBWn at

checkpoints

• Updating datafile headers with checkpoint information

• Updating control files with checkpoint information

Instance

Shared Pool

LibraryCache

DataDictionary

Cache

SGA

Database BufferCache

Redo LogBuffer

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

Oracle DatabaseData Files Control Files Redo Log Files

Shared Pool

Page 37: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Archiver (ARCn)Archiver (ARCn)• Optional background process• Automatically archives online redo log files when

ARCHIVELOG mode is set• Preserves the record of all changes made to the

database

Oracle DatabaseData Files Control Files Redo Log Files Archived Logs

ARCn

Page 38: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Oracle Data StorageOracle Data Storage

Oracle keeps all system and user data in two basic storage containers:

1. Tablespace… a logical entity known only to Oracle

2. Data Files… physical files that may (typically) be seen from the operating system

Page 39: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

TablespacesTablespaces

• Can belong to only one database at a time

• Consist of one or more data files

• Are further divided into logical units of store

Page 40: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Data FilesData Files

• Can belong to only one tablespace and one database

• Are a repository for schema object data

DataFile

DataFile

Database

Tablespace

Page 41: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

2 Types of Tablespace2 Types of Tablespace

1. Tablespaces required by Oracle for normal operations

2. Tablespaces that contain data and indexes that support your applications

Page 42: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Required TablespacesRequired Tablespaces

• System – Contains the Oracle Data Dictionary

• Sysaux - New to 10g; supports historic monitoring / tuning

• Temporary – Used for disk-based sorting of data (select...from…order by)

• Undo – Used for transaction consistency during Insert / Update / Delete statements

Page 43: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

SQL Statements (IUDS)SQL Statements (IUDS)

• Insert

• Update

• Delete

• Select

What happens when someone connects to the database and issues one of these statements?

Page 44: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Connect to Oracle – What HappensConnect to Oracle – What Happens

ServerProcess

UserProcess

Connect User/Pwd

• Are “User” definition and privileges in SGA “Dictionary Cache”?– If not, try to fetch from the “System”

tablespace– If there, validate Pwd and privileges to login– Allow connection if all is right; otherwise

decline connection

Page 45: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

““Select” – What Happens First?Select” – What Happens First?

• Is this statement in the “Library Cache”?– If statement cached then it has been recently

been “parsed” and “executed”– If not cached then “parse” the statement– If cached then skip parsing stage and execute

statement

Select *From MyTabOrder by 1;

Page 46: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

““Select” – Parsing the StatementSelect” – Parsing the Statement

• Does “MyTab” exist?

• Does user have Privs to select from “MyTab”

• What columns are in “MyTab”

• What is the first column in “MyTab”

Select *From MyTabOrder by 1;

Page 47: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

““Select” – Executing the StatementSelect” – Executing the Statement

• Is “MyTab” data in the SGA “Buffer Cache”?– If not, fetch data into Buffer Cache

• Sort data in “MyTab” by the first column– If can sort records in memory then do so– If cannot sort in memory then use “Temporary”

tablespace as disk-based staging area

• Return records to client process

Select *From MyTabOrder by 1;

Page 48: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

““I/U/D” – What Happens First?I/U/D” – What Happens First?

• Is this statement in the “Library Cache”?– If statement cached then it has been recently

been “parsed” and “executed”– If not cached then “parse” the statement– If cached then skip parsing stage and execute

statement

Insert (a,b,c)Into MyTab;

Page 49: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

““I/U/D” – Executing the StatementI/U/D” – Executing the Statement

• Validate values to be inserted• Execute the statement

– Keep DB version of the record in “Undo” tablespace until Commit or Rollback

– Record changes in SGA “Redo Log Buffer”– Change records in SGA “Buffer Cache”– DBWn writes changed records to data file(s)

as part of buffer cache management

Insert (a,b,c)Into MyTab;

Page 50: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

““I/U/D” – Executing the StatementI/U/D” – Executing the Statement

• If “Commit” then…– LGWn writes “Redo Log Buffer” entries to

“Redo Logs”– Undo entries are invalidated

• If “Rollback” then…– Migrate DB version of record in Undo back to

tablespace/data file

Insert (a,b,c)Into MyTab;Commit;orRollback;

Page 51: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Archivelog ModeArchivelog Mode

Oracle DatabaseData Files Control Files Redo Log Files Archived Logs

ARCn

• If Instance in “Archivelog” mode Redo Log Files are “Archived” to Archive Logs; which may be used to recover your database in the case of disaster

Page 52: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Creating new Database

Page 53: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Managing and Organizing a Managing and Organizing a DatabaseDatabase

• Creating a database is the first step in managing a database system

• A database may have been created automatically as part of Oracle9i Server installation, or you can create a new one later

• Oracle Data Migration Assistant is used to migrate from an earlier version of the database

Page 54: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Creation PrerequisitesCreation PrerequisitesCreation PrerequisitesCreation Prerequisites

To create a new database, you must have the following:

• A privileged account authenticated in one of the following ways: – By the operating system – Using a password file

• Sufficient memory to start the instance

• Sufficient disk space for the planned database

To create a new database, you must have the following:

• A privileged account authenticated in one of the following ways: – By the operating system – Using a password file

• Sufficient memory to start the instance

• Sufficient disk space for the planned database

Page 55: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Planning Database File Planning Database File LocationsLocations

Planning Database File Planning Database File LocationsLocations

• Keep at least two active copies of a database control file on at least two different devices.

• Multiplex the redo log files and put group members on different disks.

• Separate data files whose data:– Will participate in disk resource contention

across different physical disk resources– Have different life spans– Have different administrative characteristics

• Keep at least two active copies of a database control file on at least two different devices.

• Multiplex the redo log files and put group members on different disks.

• Separate data files whose data:– Will participate in disk resource contention

across different physical disk resources– Have different life spans– Have different administrative characteristics

Page 56: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Creating a DatabaseCreating a DatabaseCreating a DatabaseCreating a Database

An Oracle database can be created using:

• Oracle Database Configuration Assistant

• The CREATE DATABASE command

An Oracle database can be created using:

• Oracle Database Configuration Assistant

• The CREATE DATABASE command

Page 57: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Using the Database Configuration AssistantUsing the Database Configuration AssistantUsing the Database Configuration AssistantUsing the Database Configuration Assistant

The Database Configuration Assistant allows you to:

• Create a database

• Configure database options

• Delete a database

• Manage templates

– Create new template using pre-defined template settings

– Create new template from an existing database

– Delete database template

Page 58: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Create a Database Create a Database

Page 59: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Database InformationDatabase InformationSpecify:• Global database name and SID• The features you want to use for your database,

such as:

– Oracle Spatial– Oracle OLAP Services– Example Schemas

• Mode in which you want the database to operate

– Dedicated server mode– Shared server mode

Page 60: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Typical or Custom InstallTypical or Custom InstallTypical or Custom InstallTypical or Custom InstallChoose between typical or custom install

Page 61: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.
Page 62: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Other ParametersOther ParametersOther ParametersOther Parameters• Archive Parameters

– Use for database recovery– May also be used for a standby database

• Data Block Sizing

– Sets the default database block size– Helps to determine the SORT_AREA_SIZE

• File Locations

– Specify paths for trace files– Specify paths for parameter files

• Database storage

– Specify storage parameters

Page 63: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Complete Database CreationComplete Database CreationComplete Database CreationComplete Database Creation

Complete database creation using the following options:

• Create database• Save as a database template• Generate database creation scripts

Page 64: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Creating a Database Creating a Database ManuallyManually

Creating a Database Creating a Database ManuallyManually

• Decide on a unique instance and database name• Choose a database character set• Set the operating system variables• Edit / Create the initialization parameter file• Start the instance (nomount)• Execute the CREATE DATABASE command• Run scripts to generate the data dictionary and

accomplish post creation steps

• Decide on a unique instance and database name• Choose a database character set• Set the operating system variables• Edit / Create the initialization parameter file• Start the instance (nomount)• Execute the CREATE DATABASE command• Run scripts to generate the data dictionary and

accomplish post creation steps

Page 65: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Preparing the Parameter FilePreparing the Parameter File

• Create the new initSID.ora

• Modify the initSID.ora by editing the parameters

$ cp init.ora $ORACLE_HOME/dbs/initdb01.ora$ cp init.ora $ORACLE_HOME/dbs/initdb01.ora

Page 66: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Creating SPFILECreating SPFILE

Create the SPFILE from initSID.ora

CREATE SPFILE FROM PFILE;CREATE SPFILE FROM PFILE;

Page 67: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Starting the InstanceStarting the Instance

• Connect as SYSDBA• Start the instance in NOMOUNT stageSTARTUP NOMOUNTSTARTUP NOMOUNT

Page 68: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

@crdbdb01.sqlSQL> create database db01 2 logfile 3 GROUP 1 ('/u01/oradata/db01/log_01_db01.rdo') SIZE 15M, 4 GROUP 2 ('/u01/oradata/db01/log_02_db01.rdo') SIZE 15M, 5 GROUP 3 ('/u01/oradata/db01/log_03_db01.rdo') SIZE 15M 6 datafile '/u01/oradata/db01/system_01_db01.dbf' SIZE 100M 7 undo tablespace UNDO 8 datafile '/u01/oradata/db01/undo_01_db01.dbf' SIZE 40M 9 default temporary tablespace TEMP 10 tempfile '/u01/oradata/db01/temp_01_db01.dbf' SIZE 20M 11 extent management local uniform size 128k 12 character set AL32UTF8 13 national character set AL16UTF16 14 set time_zone = 'America/New_York' 15 ;

@crdbdb01.sqlSQL> create database db01 2 logfile 3 GROUP 1 ('/u01/oradata/db01/log_01_db01.rdo') SIZE 15M, 4 GROUP 2 ('/u01/oradata/db01/log_02_db01.rdo') SIZE 15M, 5 GROUP 3 ('/u01/oradata/db01/log_03_db01.rdo') SIZE 15M 6 datafile '/u01/oradata/db01/system_01_db01.dbf' SIZE 100M 7 undo tablespace UNDO 8 datafile '/u01/oradata/db01/undo_01_db01.dbf' SIZE 40M 9 default temporary tablespace TEMP 10 tempfile '/u01/oradata/db01/temp_01_db01.dbf' SIZE 20M 11 extent management local uniform size 128k 12 character set AL32UTF8 13 national character set AL16UTF16 14 set time_zone = 'America/New_York' 15 ;

Creating the DatabaseCreating the Database

Page 69: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

Creating a Database Using Creating a Database Using OMFOMF

• Define the OMF initialization parameters in the

parameter file– DB_CREATE_FILE_DEST– DB_CREATE_ONLINE_DEST_n

STARTUP NOMOUNTCREATE DATABASEDEFAULT TEMPORARY TABLESPACE TEMP;

STARTUP NOMOUNTCREATE DATABASEDEFAULT TEMPORARY TABLESPACE TEMP;

Page 70: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

TroubeshootingTroubeshooting

Creation of the database fails if:

• There are syntax errors in the SQL script

• Files that should be created already exist

• Operating system errors such as file or directory permission or insufficient space errors occur

Page 71: Oracle Database Workshop 1 Presented to IBRI CAS 27-Nov-2011 By Abdullah Alkalbani.

After Database CreationAfter Database Creation

The database contains:• Datafiles, control files, and redo log files• User SYS with the password change_on_install

• User SYSTEM with the password manager

• Internal tables (but no data dictionary views)