database lab.dblab.sangji.ac.kr/downloads/dbp/no02-oracle concecpts.pdf · 2013-09-13 ·...

15
데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교 컴퓨터정보공학부 Database Lab. Oracle Concepts http://otn.oracle.com "Oracle 9i Concepts" Contents 1 Introduction to Oracle Server 2 Oracle Server Architecture 2.1 Oracle Memory Structure 2.2 Oracle Processes 2.3 An Example of How Oracle Works 2.4 Oracle Database Structures 2.5 Database and Instance Startup 2.6 Database and Instance Shutdown 1 Oracle System Architecture and Concetps 1. Introduction to Oracle Server Introduction to Databases and Information Management client/server environment large database and space management concurrent database users connectibility high transaction processing performance manageable security database enforced integrity

Upload: others

Post on 01-Apr-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

Oracle Conceptshttp://otn.oracle.com "Oracle 9i Concepts"

Contents제 1 장 Introduction to Oracle Server제 2 장 Oracle Server Architecture

2.1 Oracle Memory Structure2.2 Oracle Processes2.3 An Example of How Oracle Works2.4 Oracle Database Structures2.5 Database and Instance Startup2.6 Database and Instance Shutdown

제 1 장 Oracle System Architecture and Concetps

1. Introduction to Oracle ServerIntroduction to Databases and Information Managementclient/server environmentlarge database and space managementconcurrent database usersconnectibilityhigh transaction processing performancemanageable securitydatabase enforced integrity

Page 2: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

제 2 장 Oracle Server Architecture

The Oracle Server- Object-Relational Database Management Systems- Oracle Server consists of

an Oracle Databasean Oracle Server Instance

Memory

Oracle Server

OracleInstanceDatabaseDatabase

OracleServices

2.1 Oracle Memory Structurel Basic memory structures

- System Global Area(SGA) which includesŸ database buffers, redo log buffers, and the shared pool

- Program Global Areas(PGA)Ÿ Stack AreasŸ Data Areas

- Software Code Areas- Sort Area

l SGA(System Global Area)- shared memory region that contains

Ÿ data and control information for "one" Oracle instance

- An SGA and Oracle Background ProcessesŸ constitute an "Oracle Instance

Page 3: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

l Oracle Instance- Each instance has its own "System Global Area"

SGA(system

global area)Oracle

BackgroundProcesses

memory

area of memory used for database information shared by the database users

two type of process :- user processes

- application program or oracle tool- oracle processes

- server processes

l System Global Area(SGA)- Database Buffers

Ÿ most recently used blocks of data- Redo Log Buffer- Shared Pool

Ÿ Library Cache- Shared SQL Areas : parse tree and execution plan- PL/SQL Program Unit : the parsed, compiled form of a program unit

Ÿ Dictionary Cache- a collection of database tables and views containing reference

information about the database, its structures, and its usersŸ Control Structures

Shared SQL area must be available to multiple users

Page 4: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

l PGA(Program Global Areas)- a memory buffer that contains data and control information for a server

process- non-shared area

Ÿ One PGA is allocated for each server process-- PGA is allocated by Oracle

Ÿ when a user connects to an Oracle database and a session is created

l summary of memory structure- SGA

Ÿ Database BufferŸ Redo Log BufferŸ Shared Pools

- Library cache(Shared SQL area, PL/SQL Unit) Dictionary Cache- PGA-

Page 5: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

2.2 Oracle Processes

1. Introduction to Oracle Server2. Oracle Server Architecture

2.1 Oracle Memory Structure2.2 Oracle Processes2.3 An Example of How Oracle Works2.4 Oracle Database Structures2.5 Database and Instance Startup2.6 Database and Instance Shutdown

l Process Architecture- User Process- Oracle Processes

Ÿ Server ProcessesŸ Background Processes

DBWn, LGWR, CKPT, PMON, SMON, ...

l User Process is created to execute - the application program(PRO*C program) or - an Oracle tool(Developer)

l User Process manages- the communication with the server processes - through the program interface

l Server Processes- handle requests from connected user processes- interact with Oracle to carry out requests of user process- EX) User queries some data is not in DB buffer of SGA, server process

reads data blocks from datafiles into SGA

l Background Processes- Oracle creates a set of background processes for each instance

Ÿ DBWn : database writerŸ LGWR : log writerŸ CKPT : checkpointŸ SMON : system monitorŸ PMON : process monitorŸ Recoverer

Page 6: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

2.3 An Example of How Oracle Works1. Introduction to Oracle Server2. Oracle Server Architecture

2.1 Oracle Memory Structure2.2 Oracle Processes2.3 An Example of How Oracle Works2.4 Oracle Database Structures2.5 Database and Instance Startup2.6 Database and Instance Shutdown

DatabaseDatabase

oracle instance

Client application

net8 driver

(1)

(2)(8)(4)

(5)

(6)

(7-1)

(7-2)(3)

1. An oracle instance is currently running on Oracle(DB server)2. Client application attempts to establish a connection using Net 8 driver3. The server detects the connection request from the application and creates a

(dedicated) server process4. The user executes a SQL stmt and commits the transaction5. The Server receives the statements.

1. If a shared SQL area is found, the server process checks user's access privileges

2. If not, a new shared SQL area is allocated for the stmt so that it can be parsed and processed

6. The server process retrieves any necessary data from the actual datafile or those stored in SGA

7. The server process modifies the data in SGA. The DBWn process writes modified blocks to disk

8. If the transaction is successful, the server process sends a message across the

Page 7: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

network to the application

2.4 Oracle Database Structures

1. Introduction to Oracle Server2. Oracle Server Architecture

2.1 Oracle Memory Structure2.2 Oracle Processes2.3 An Example of How Oracle Works2.4 Oracle Database Structures2.5 Database and Instance Startup2.6 Database and Instance Shutdown

l Oracle database- is a collection of data that is treated as a unit- has logical structure and physical structure

Ÿ The logical structures of an Oracle database tablespaces, schema objects, data blocks, extents, and segments.

Ÿ physical database structures of an Oracle database - datafiles, redo log files, and control files.

l Logical Database Structure

1. Tablespace- A database is divided into logical storage units called tablespaces

Ÿ System Tablespace(1) Data Dictionary Tables for the entire database(2) PL/SQL Program Units

Ÿ procedures, functions, packages, triggersŸ if the database will contain many of these program units, the

database administrator needs to allow for more space in the SYSTEM tablespace

Ÿ User Tablespacefor user data

Page 8: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

Ÿ Using Multiple Tablespacesa small database need only the SYSTEM tablespace

- recommendation :- at least one additional tablespace to store user data separate from data dictionary

You can use multiple tablespaces to- control disk space allocation for user data - assign specific space quotas for database users- perform partial database backup or recovery operations

2. Schema and Schema Objectsl schema

- a collection of database objectsl schema objects

- the logical structures that directly refer to the database's data- for example,

Ÿ tables, view, indexes, cluster, stored procedures

3. Data Blocks, Extents, and Segments

l Oracle Data BlockŸ the finest level of granularityŸ database data is stored in data blockŸ also called logical blocks, oracle blocks or pagesŸ a specific number of bytes of physical database on diskŸ the smallest unit of I/O used by a databaseŸ block size

is determined when you create the databaseshould be a multiple of the O.S's block size

l ExtentsŸ specific number of contiguous data blocksŸ used to storing a specific type of information

l SegmentsŸ a set of extentsŸ each of which has been allocated for a specific data structureŸ all of which are stored in the same tablespaceŸ for example

- each user data is stored in its own data segment- each index data is stored in its own index segment

Page 9: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

Ÿ a set of extents allocated for a certain logical structuredata segmentindex segmentrollback segment

Page 10: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

l Physical Database Structure 1. Datafiles

- datafiles contain all the database data- A datafile can be associated with only one database- one or more datafiles => tablespace

2. Redo Log and Control Files- Redo Log Files

Ÿ Every Oracle database has a set of two or more redo log filesŸ database's redo log

- Control FilesŸ entries that specify the physical structure of the database

database namenames and locations of datafilestimestamp of database creation

************ summaryl Logical Database Structures

- tablespaces, schema objects, data blocks, extents, and segments.

l physical database structures - datafiles, redo log files, and control files.

************

Page 11: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

l Database, Tablespaces and Datafiles

- capacity of Tablespace= total size of tablespace’s datafiles

- capacity of database= total capacity of database’s tablespace

2MB 4MB

6MB datafile

Databases, tablespaces, and datafiles are closely related, but they have important differences:

Page 12: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

l databases and tablespaces- An Oracle database consists of one or more logical storage units called

tablespaces, - which collectively store all of the database's data.

l tablespaces and datafiles- Each tablespace in an Oracle database consists of one or more files called

datafiles, - which are physical structures that conform with the operating system in which

Oracle is running.l databases and datafiles

- A database's data is collectively stored in the datafiles that constitute each tablespace of the database.

- For example, Ÿ the simplest Oracle database would have one tablespace and one

datafile. Ÿ Another database might have three tablespaces, each consisting of two

datafiles (for a total of six datafiles).

l Allocating More Space for a Database1. Add a datafile to a tablespace

Page 13: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

2. Add a new tablespace

3. Allocating More Space for a DatabaseŸ Increase the size of a datafile

Page 14: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

2.5 Database and Instance Startup1. Introduction to Oracle Server2. Oracle Server Architecture

2.1 Oracle Memory Structure2.2 Oracle Processes2.3 An Example of How Oracle Works2.4 Oracle Database Structures2.5 Database and Instance Startup2.6 Database and Instance Shutdown

l when a database is started on a database server, - Oracle allocates a memory area called the System Global Area(SGA)- and starts one or more Oracle processes

l combination of SGA and Oracle processes- Oracle Instance

l The Instance and Database1. starting an instance

Ÿ reads a parameter file to initialize the databaseŸ allocates an SGAŸ creates background processesŸ at this point, no database is associated with an SGA and processes

Page 15: Database Lab.dblab.sangji.ac.kr/downloads/dbp/No02-Oracle Concecpts.pdf · 2013-09-13 · 데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조 상지대학교

데이터베이스 프로그래밍 - No2. 오라클 소개 및 시스템 구조

상지대학교 컴퓨터정보공학부

Database Lab.

2. mounting a databaseŸ to associate the database with that instanceŸ The instance opens the database control filesŸ and then, the names of the database's datafiles and redo log files

3. opening a databaseŸ makes it available for normal database operations

2.6 Database and Instance shutdown

1. Introduction to Oracle Server2. Oracle Server Architecture

2.1 Oracle Memory Structure2.2 Oracle Processes2.3 An Example of How Oracle Works2.4 Oracle Database Structures2.5 Database and Instance Startup2.6 Database and Instance Shutdown

l Close the database- Oracle writes all database data and recovery data in the SGA to the datafiles

and redo log filesl Dismount the database

- to disassociate it from the instance- Oracle closes the control files of the database.

l Shutdown the instance- the SGA is removed from memory and the background processes are

terminated.