You are on page 1of 30

1

Understanding the Oracle Database


Environment

Copyright © 2004, Oracle. All rights reserved.


Objectives

After completing this lesson, you should be able to do


the following:
• Identify Oracle database components
• Define an instance and how to connect to it
• Describe the parsing of a SQL statement
• Describe the processing of a SQL statement
• Declare, reference, and display bind variables
• Describe read consistency

1-2 Copyright © 2004, Oracle. All rights reserved.


Understanding the Oracle Database
Environment

Oracle
Database 10g

Oracle AS 10g

Clients

1-3 Copyright © 2004, Oracle. All rights reserved.


1-4 Copyright © 2004, Oracle. All rights reserved.
Getting to Know the Oracle Database

Data concurrency Security


and consistency Manageability

Business Content
intelligence management
Backup and
recovery

1-5 Copyright © 2004, Oracle. All rights reserved.


1-6 Copyright © 2004, Oracle. All rights reserved.
Demystifying Grid Computing

Storage grid Database grid Application Server


grid

1-7 Copyright © 2004, Oracle. All rights reserved.


Exploring the Architectural Components
Instance
User
process SGA Shared pool
Library
Database cache
Redo log
buffer
Server buffer Data dict.
cache cache
process
PGA
SMON DBW0 PMON CKPT LGWR Others

Data Control Redo


Parameter files files log files
file
Archived
log files
Password
file Database

1-8 Copyright © 2004, Oracle. All rights reserved.


1-9 Copyright © 2004, Oracle. All rights reserved.
Exploring the Architectural Components

Data Control Redo


files files log files

Database

Oracle database files

1-10 Copyright © 2004, Oracle. All rights reserved.


Exploring the Architectural Components

Parameter
file
Archived
log files
Password
file Database

Other key physical structures

1-11 Copyright © 2004, Oracle. All rights reserved.


Understanding the Oracle Instance

An Oracle instance:
• Is a means to access an Oracle database
• Always opens only one database

Instance

SGA Shared pool


Memory
Database structures
Redo log
buffer
buffer
cache

Background
SMON DBW0 PMON CKPT LGWR Others processes

1-12 Copyright © 2004, Oracle. All rights reserved.


1-13 Copyright © 2004, Oracle. All rights reserved.
Connecting to an Instance

User Server

User Server

Oracle server

Client

Application server Server


User Server

Browser

1-14 Copyright © 2004, Oracle. All rights reserved.


1-15 Copyright © 2004, Oracle. All rights reserved.
Processing a SQL Statement

• You connect to an instance by using:


– The user process
– The server process
• The Oracle server components that are used
depend on the type of the SQL statement:
– Queries return rows
– DML statements log changes
• A cursor is used to parse SQL statements.

1-16 Copyright © 2004, Oracle. All rights reserved.


Processing a SQL Statement

Parsing and
execution

Client Server

1-17 Copyright © 2004, Oracle. All rights reserved.


1-18 Copyright © 2004, Oracle. All rights reserved.
Understanding Data Flow During SQL
Statement Processing
Data retrieval

Client Server Database

Instance
Client
SGA Shared pool
Library
Database cache
Redo log
buffer Data Dict.
buffer
cache cache

SMON DBW0 PMON CKPT LGWR Others

1-19 Copyright © 2004, Oracle. All rights reserved.


1-20 Copyright © 2004, Oracle. All rights reserved.
Using Bind Variables

In cache:

SELECT salary FROM employees WHERE employee_id


= 100;

Not similar Hard parse done


For processing:
SELECT salary FROM employees WHERE employee_id
= 102;

Using a bind variable:


SELECT salary FROM employees WHERE employee_id
= :eid;

1-21 Copyright © 2004, Oracle. All rights reserved.


Using Bind Variables

Declaring a variable in iSQL*Plus to be used as a bind variable:

VARIABLE eid NUMBER

Referencing bind variables:

SELECT salary FROM employees WHERE employee_id


= :eid;

Displaying the results of a bind variable in iSQL Plus:

PRINT eid

1-22 Copyright © 2004, Oracle. All rights reserved.


Understanding Read Consistency

• Read consistency guarantees a consistent view of


the data at all times.
• Changes made by one user do not conflict with
changes made by another user.
• Read consistency ensures that on the same data:
– Readers do not wait for writers or other readers
– Writers do not wait for readers

1-23 Copyright © 2004, Oracle. All rights reserved.


Understanding Read Consistency

Data
blocks
UPDATE employee
SET salary = 7000 Rollback
WHERE last_name = ‘Fay’; segments
User A
Changed
and
SELECT * unchanged
FROM userA.employee; Read data
consistent
User B image “Old” data
before
change

1-24 Copyright © 2004, Oracle. All rights reserved.


Understanding Read Consistency

Output Time Session 1 Session 2

24000 t1 SELECT salary FROM employee


WHERE last_name='King';

UPDATE employee
t2 SET salary=salary+10000
WHERE last_name='King';

24000 t3 SELECT salary FROM employee


WHERE last_name='King';
t4 COMMIT;

SELECT salary FROM employee


34000 t5 WHERE last_name='King';

1-25 Copyright © 2004, Oracle. All rights reserved.


Summary

In this lesson, you should have learned how to:


• Identify Oracle Database components
• Define an instance and how to connect to it
• Describe the parsing of a SQL statement
• Describe the processing of a SQL statement
• Declare, reference, and display bind variables
• Describe read consistency

1-26 Copyright © 2004, Oracle. All rights reserved.


Practice 1: Overview

This practice covers the following topics:


• Identifying Oracle Database components
• Defining an instance and how to connect to it
• Describing the parsing of a SQL statement
• Describing the processing of a SQL statement
• Declaring, referencing, and displaying bind
variables
• Describing read consistency

1-27 Copyright © 2004, Oracle. All rights reserved.


1-28 Copyright © 2004, Oracle. All rights reserved.
1-29 Copyright © 2004, Oracle. All rights reserved.
1-30 Copyright © 2004, Oracle. All rights reserved.

You might also like