Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control...

27
Chapter 10 1 Chapter 10

Transcript of Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control...

Page 1: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 1

Chapter 10

Page 2: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 2

Oracle Server

• An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define and manipulate data and PL/SQL to control the flow of SQL, allow the use of variable & error handling procedures

• Oracle Instance which is made up of the various processes (both system and user) to support a specific instance.

Page 3: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 3

Oracle Database Structure

• One or more Data files

• Two or more Log files called redo files. This files are used in recovery and trace the source of specific transaction.

• One or more Control files which contain the database name, related file names and locations and the creation timestamp.

Page 4: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 4

Oracle Database Structure (con’t)

• Trace Files and alert Log

• A database is defined in terms of Schema Objects and Tablespaces.– Schema Objects contain definitions of tables,

views, sequences, stored procedures indexes, clusters and database links.

– Tablespaces, segments and extents are the terms used to describe the physical storage.

Page 5: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 5

Oracle Instance

• System Global Area (SGA): Real memory area where database information is shared by users. For performance it should be as large as possible.

Page 6: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 6

System Global Area

• SGA is further divided into 3 areas.– Database buffer cache: Most recently accessed

data blocks from the database.– Redo log buffer – Shared pool, contains shared memory

constructs; such as, shared SQL area which is made up of parse trees of SQL queries & execution plans for executing SQL statements.

Page 7: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 7

Oracle Instance Processes

• User processes: A user process is created for the execution of some application.

• Program Global Area (PGA): Contains data and control information for the server processes.

• Oracle Processes: A Process or Thread of control which is assigned a private memory area in which it runs.

Page 8: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 8

Oracle Processes

• Oracle creates Server Processes to handle requests. This is a multithreaded server operation for efficiency rather than creating a separate process for each request to the server.

Page 9: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 9

Oracle Background Processes

• Database Writer (DBWR): Writes those blocks that were modified from the cache to the disk

• Log Writer (LGWR): Writes from the log buffer to the online disk log file.

• Checkpoint (CKPT): Refers to an event during which all the modified buffers in the SGA since the last checkpoint are written to the data files. It works with DBWR.

Page 10: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 10

Oracle Background Processes

• System Monitor(SMON): Performs instance recovery, manages storage areas by making the space contiguous & recovers transactions.

• Process Monitor(PMON): Performs process recovery when a user process fails. It manages the cache and other resources used by a user process.

Page 11: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 11

Oracle Background Processes

• Archiver (ARCH): Archives on-line log files to archival storage location; such as, disk or tape ( if configured to do so).

• Recoverer Process(RECO): Resolves distributed transactions that are pending due to a network or system failure in a Distributed database.

Page 12: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 12

Oracle Background Processes

• Dispatchers (Dnnn): In a multi-threaded server configurations, routes requests from the connected user processes to available shared server processes. There is 1 dispatcher per standard communication protocol supported.

• Lock Processes(LCKn): Used for inter-instance locking when Oracle in Parallel Mode

Page 13: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 13

Oracle Startup & Shutdown

• Starting an Instance: This is where the SGA is allocated, the background processes are created and the instance is initialized.

• Mounting the Database: This associates a database with an instance. This is one step that is required to make the database available to users.

Page 14: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 14

Oracle Startup & Shutdown

• Opening a database: This is the second operation needed to make the database available to users. It opens the on-line data files and the log files.

• The reverse of the above procedure is used to shutdown the database.

• These are ALL actions done by the DBA.

Page 15: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 15

Schema Objects

• TABLES: Tables are the basic unit that is used in Oracle to store data. It conforms with the relational model. Each column has a column name, datatype and width.

• Views: View are virtual tables which on defined either on other views or tables.

Page 16: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 16

Schema Objects

• Synonyms: Direct references to objects. They are used to provide public access to an object while masking its real name or owner. Private synonyms may be created that are only available to that user.

• Program Unit: Procedures, functions or packages written in PL/SQL

Page 17: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 17

Schema Objects

• Sequence: A special provision of a data type in Oracle for attribute value generation.

• Indexes: An index can be generated on one or more columns of a table as requested using SQL.

Page 18: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 18

Schema Objects

• Cluster: A group of records from one or more tables physically stored in a mixed file. This is to improve performance. Such as using an Index Cluster.

• Database Links: Named objects in Oracle that establish paths from one database to another. (Used in distributed databases.)

Page 19: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 19

Oracle’s Data Dictionary

• This is made up of a read-only set of tables that store the Metadata. Access to the information in these tables is usually done through views .

• These views begin with one of three special prefixes: USER,DBA, or ALL.

Page 20: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 20

Item in the Data Dictionary

• Names of users

• Security Information: Privileges and roles.

• Schema Object Information

• Integrity constraints

• Space Allocation & Utilization of the database objects.

• Statistics on attributes, tables and predicates.

• Access audit trail information.

Page 21: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 21

Triggers

• There are some business rules that we wish to actively enforce every time some action is done; such as, insert, delete or update. In Oracle this is done through the use of triggers.

• Triggers either enforce additional constraints or perform additional actions.

Page 22: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 22

Storage

• Each Database is divided into one or more different tablespaces.

• As a minimum there is always a System and Users tablespace.

• These tablespaces are stored in one or more data files.

• These data files are associated with only one database.

Page 23: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 23

Physical Storage• Physical Storage is organized in terms of data

blocks, extents and segments.

• Data blocks are the finest (smallest) size of storage. They are also called logical blocks, page or Oracle blocks.

• An Extent is a specific number of contiguous data blocks.

• A Segment is a set of extents for a data structure.

Page 24: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 24

Data Blocks

• A Data Block has the following components:– Header: Contains the general block information

such as block address & type of segment.– Table Directory: Contains information about

tables that have data in the data block.– Row Directory: Contains information about the

actual rows.

Page 25: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 25

Data Blocks (con’t)

– Row Data: Uses the bulk of the space of the Data Block. A row may span multiple blocks.

– Free Space: Space allocated for row updates and new rows.

Page 26: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 26

Extents

• The amount of space initial allocated to an extent is determine by the ‘Create’ command. Incremental extents are allocated when the initial one becomes full and their size is determined by ‘Create’ command.

• All extents allocated to index exist as long as the index exists.

Page 27: Chapter 101. 2 Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.

Chapter 10 27

Segments

• There are four types of Segments:– Data segments: Each non-clustered table and

each cluster has a Single data segment.– Index segments: Each index has a single index

segment.– Temporary segments: Used by SQL as a

temporary work area.– Rollback segments: Used for undoing

transactions.