Introduction to Oracle

Download Report

Transcript Introduction to Oracle

Anton Topurov IT-DB
23 April 2013
Introduction to Oracle
2
23 April 2013
Introduction to Oracle
3
23 April 2013
Introduction to Oracle
4
IT manager
23 April 2013
Introduction to Oracle
5
App Developer
23 April 2013
Introduction to Oracle
6
Database Administrator
23 April 2013
Introduction to Oracle
7
System Administrator
23 April 2013
Introduction to Oracle
8
IT manager
23 April 2013
Introduction to Oracle
9
23 April 2013
Introduction to Oracle
10
23 April 2013
Introduction to Oracle
11
Introduction to Oracle
12
23 April 2013
Introduction to Oracle
13
Oracle Database Internals
23 April 2013
Introduction to Oracle
14
Real Application Clusters (RAC)
23 April 2013
Introduction to Oracle
15
23 April 2013
23 April 2013
Introduction to Oracle
Introduction to Oracle
16
16
Oracle Database Server
23 April 2013
Introduction to Oracle
17
Simplified view
System Global Area (SGA)
PGA
Background
Processes
Server Processes
Data Files
23 April 2013
Control Files
Online Redo Logs
Introduction to Oracle
18
Database Physical Layout
Data Files
Control Files
23 April 2013
Online Redo Logs
Introduction to Oracle
19
Physical to Logical
Data Files
23 April 2013
Introduction to Oracle
20
Logical Layout
Block
•
Tablespace
The smallest
logical unit
of data storage
•
Maps to one or more
datafiles
Extent
Segment
•
•
Type (table, index,..)
•
Within a tablespace
Continios set of
blocks
23 April 2013
Introduction to Oracle
21
Real Application Clusters (RAC)
23 April 2013
Introduction to Oracle
22
Oracle Instance
System Global Area (SGA)
Background
Processes
Data Files
23 April 2013
Control Files
Online Redo Logs
Introduction to Oracle
23
SGA contents
Shared pool
•
shared memory constructs
like shared SQL areas
•
most recently executed SQL
statements
•
most recently used data
definitions
Buffer cache
23 April 2013
•
holds copies of data blocks
•
server processes manipulate
data from buffer cache (not
directly from data files)
•
managed using LRU algorithm
(Least Recently Used)
Introduction to Oracle
24
Background Processes
System Monitor
Buffer Cache System Global Area (SGA)
Redo
Log
Buffer
Process Monitor
Diagnosability Process
Database Writer
Checkpointer
Redo Log Writer
Redo Log Archiver
Backup
Data Files
Control Files
23 April 2013
Online Redo Logs Archived Redo Logs
Introduction to Oracle
25
Real Application Clusters (RAC)
23 April 2013
Introduction to Oracle
26
Real Application Clusters
SGA
SGA
PGA
PGA
SGA
Clusterware
Clusterware
PGA
Data Files
Control Files
23 April 2013
Online Redo Logs
Introduction to Oracle
27
Real Application Clusters (RAC)
23 April 2013
Introduction to Oracle
28
Database Account
•
Database user
•
•
Privileges
•
•
•
username/password to connect to database
System and object privileges / roles
•
CREATE SESSION, CREATE TABLE, CREATE PROCEDURE, CREATE JOB,…
•
EXECUTE ON DBMS_LOCK, SELECT ON HR.EMPLOYEES, …
Profiles
•
CERN_DEV_PROFILE: 10 concurrent sessions
•
CERN_APP_PROFILE: 400 concurrent sessions
Space quota on tablespaces
23 April 2013
Introduction to Oracle
29
Database vs Schema
A Schema?
• Collection of objects
• Owned by a database user and has the
same name as that user
• Each user owns a single schema.
• Good programming practice is to prefix
objects by schema name
select name from hr.employees where id=7;
23 April 2013
Introduction to Oracle
30
Connecting to Oracle Database
Instance SID: DEVDB11
sqlplus username@
’( DESCRIPTION=
(ADDRESS= (PROTOCOL=TCP)
SGA
(HOST=node1.cern.ch) (PORT=10121))
(CONNECT_DATA= (SID=DEVDB11)))’
PGA
Listener
port 10121
node1
Data Files Control Files Online Redo Logs
23 April 2013
Introduction to Oracle
31
Connecting to RAC Database
sqlplus username@ ( DESCRIPTION=
(ADDRESS= (PROTOCOL=TCP) (HOST=node2-v.cern.ch) (PORT=10121))
(ADDRESS= (PROTOCOL=TCP) (HOST=node1-v.cern.ch) (PORT=10121))
(LOAD_BALANCE=off) (CONNECT_DATA= (SERVER=DEDICATED)
(SERVICE_NAME=CERN_SRV1.cern.ch) ))’
node1.cern.ch
node2.cern.ch
SGA
SGA
PGA
PGA
Listener
Listener
node1-v
node2-v
Clusterware
CERN_SRV1
CERN_SRV2
CERN_SRV3
Data Files
23 April 2013
Clusterware
Control Files
Online Redo Logs
Introduction to Oracle
32
Local naming method
sqlplus username@
( DESCRIPTION=
cerndb1 =
(ADDRESS= (PROTOCOL=TCP) (HOST=node2-v.cern.ch) (PORT=10121))
(ADDRESS= (PROTOCOL=TCP) (HOST=node1-v.cern.ch) (PORT=10121))
(LOAD_BALANCE=off) (CONNECT_DATA= (SERVER=DEDICATED)
(SERVICE_NAME=CERN_SRV1.cern.ch) ))’
Based on tnsnames.ora
/afs/cern.ch/project/oracle/admin
\\cern.ch\dfs\Applications\Oracle\ADMIN
23 April 2013
Introduction to Oracle
33
Real Application Clusters (RAC)
23 April 2013
Introduction to Oracle
34
SQL Statements Processing
select * from hr.employees;
SQL Statement
Parsing
Syntax Check
Semantic Check
Shared Pool
Check
select *= from
sql_id
8k3hpjw6yjup5
hr.employees;
Hard Parse
Optimization
Soft
Parse
select name from hr.employees where id=:id_val;
Row Source
Generation
Execution
23 April 2013
Introduction to Oracle
35
Summary
23 April 2013
Introduction to Oracle
36
Documentation
•
Oracle Database Concepts
http://docs.oracle.com/cd/E11882_01/server.112/e25789/toc.htm
•
Oracle 11g documentation
•
http://www.oracle.com/pls/db112/portal.all_books
•
Architecture poster
23 April 2013
Introduction to Oracle
37
23 April 2013
Introduction to Oracle
38