+ All Categories
Home > Documents > Introduction To Oracle

Introduction To Oracle

Date post: 01-Jan-2016
Category:
Upload: tashya-stokes
View: 23 times
Download: 0 times
Share this document with a friend
Description:
Introduction To Oracle. Before Databases. Information was kept in files: Each field describes one piece of information about student Fields are separated by commas A record is a collection of related fields Each record is a separate line. Problems with Files. - PowerPoint PPT Presentation
Popular Tags:
45
INTRODUCTION TO ORACLE
Transcript
Page 1: Introduction To Oracle

INTRODUCTION TO ORACLE

Page 2: Introduction To Oracle

2

Before Databases

Information was kept in files: Each field describes one piece of information about

student Fields are separated by commas A record is a collection of related fields Each record is a separate line

Page 3: Introduction To Oracle

3

Problems with Files

Proliferation of data management programs to deal with different file formats

Redundant data stored in files

Data files may contain inconsistent data

Page 4: Introduction To Oracle

4

Database Approach

Database stores all organizational data in a central location

Good database design eliminates redundant data to reduce the possibility of inconsistent data

Single application called the database management system (DBMS) performs all routine data handling operations

Database administrator (DBA): person responsible for installing, administering, and maintaining the database

Page 5: Introduction To Oracle

5

Types of database models

hierarchical model network model relational model object oriented model.

Page 6: Introduction To Oracle

6

Early Databases – Hierarchical Structure

Page 7: Introduction To Oracle

7

Relational Databases

Page 8: Introduction To Oracle

8

Object-oriented Example

StudentsCourses

Page 9: Introduction To Oracle

9

Relational Database Terms

Entity: an object about which you want to store data

Relationships: links that show how different records are related

Key Fields: establish relationships among records in different tables

Five main types of key fields: primary keys candidate keys foreign keys composite keys

Page 10: Introduction To Oracle

10

Primary Keys

Primary key Value must be unique for each

record Serves to identify the record Present in every record Can’t be NULL Should be numeric

Page 11: Introduction To Oracle

11

Candidate Keys

Candidate key Any field that could be used as the

primary key Should be a unique, unchanging

numeric field

Page 12: Introduction To Oracle

12

Foreign Keys

Foreign key: a field in a table that is a primary key in another table

Foreign key creates a relationship between the two tables

Foreign key value must exist in the table where it is a primary key

Page 13: Introduction To Oracle

13

Composite Keys

Composite key: a unique key that you create by combining two or more fields

Usually comprised of fields that are primary keys in other tables

Page 14: Introduction To Oracle

Database Architecture

Grid Architecture: With grid computing, groups of independent, modular hardware and software components can be connected and rejoined on demand to meet the changing needs of businesses.

Application Architecture: Client/server Multitier

Page 15: Introduction To Oracle

15

Client/Server Database Management Systems

Client/server database

Takes advantage of distributed processing and

networked computers by distributing processing across

multiple computers

DBMS server process runs on one workstation, and the

database applications run on separate client

workstations across the network

Preferred for database applications that retrieve and

manipulate small amounts of data from databases

containing large numbers of records because they

minimize network traffic and improve response times

Organizations generally use a client/server database if the

database will have more than 10 simultaneous users and if

the database is mission critical

Page 16: Introduction To Oracle

16

Client/Server Database Architecture

Page 17: Introduction To Oracle

17

The Oracle Client/Server Database Oracle11i is the latest release of Oracle Corporation’s

relational database All Oracle server- and client-side programs use Oracle

Net, a utility that enables the network communication between the client and the server

Page 18: Introduction To Oracle

18

Client-Side Utilities

SQL*Plus for creating and testing command-line SQL queries and

executing PL/SQL procedural programs Oracle9i Developer Suite

for developing database applications including the following Developer tools:

Forms Builder for creating custom user applications

Reports Builder for creating reports for displaying, printing, and distributing

summary data Enterprise Manager

for performing database administration tasks such as creating new user accounts and configuring how the DBMS stores and manages data

Page 19: Introduction To Oracle

19

Design Principles

To avoid creating tables that contain redundant data, group related items that describe a single entity together in a common table

Do not create tables that duplicate values many times in different rows

When creating a database and inserting data values, you must specify the data type for each column

Recall that primary key fields should use a number data type to avoid typographical, punctuation, and case variation errors

Page 20: Introduction To Oracle

20

The Northwoods University Student Registration Database

Northwoods University Decided to replace its aging

mainframe-based student registration system with a more modern client/server database system

School officials want students to be able to retrieve course availability information, register for courses, and print transcripts using personal computers located in the student computer labs

Page 21: Introduction To Oracle

21

The Northwoods University Student Registration Database (cont)

Faculty members must be able to retrieve student course lists, drop and add students, and record course grades

Faculty members must also be able to view records for the students they advise

Security is a prime concern, so student and course records must be protected by password access

Page 22: Introduction To Oracle

22

Northwoods University Data Requirements

Student name, address, telephone number, class (freshman, sophomore, junior, or senior), date of birth, PIN (personal identification number), and advisor ID

Course call number (such as MIS 101), course name, credits, location, duration, maximum enrollment, instructor, and term offered

Instructor name, office location, telephone number, rank, and PIN

Student enrollment and grade information

Page 23: Introduction To Oracle

23

Northwoods University Table Relationships

Page 24: Introduction To Oracle

Oracle Physical Structures

Datafiles (*.dbf) The datafiles contain all the database data. The data of logical

database structures, such as tables and indexes, is physically stored in the datafiles allocated for a database.

Control Files (*.ctl) Every Oracle database has a control file. A control file contains

entries that specify the physical structure of the database such as Database name and the Names and locations of datafiles and redo log files.

Redo Log Files (*.log) The primary function of the redo log is to record all changes made to

data. If a failure prevents modified data from being permanently written to the datafiles, then the changes can be obtained from the redo log, so work is never lost.

Page 25: Introduction To Oracle

Physical Structures (cont’d)

Archive Log Files (*.log) Oracle automatically archives log files when the database is in

ARCHIVELOG mode. This prevents oracle from overwriting the redo log files before they have been safely archived to another location.

Parameter Files (initSID.ora) Parameter files contain a list of configuration parameters for that

instance and database.

Alert and Trace Log Files (*.trc) Each server and background process can write to an associated trace file.

When an internal error is detected by a process, it dumps information about the error to its trace file. The alert log of a database is a chronological log of messages and errors.

Page 26: Introduction To Oracle

Logical Structures

Tablespaces A database is divided into logical storage units called

tablespaces, which group related logical structures together. One or more datafiles are explicitly created for each tablespace to physically store the data of all logical structures in a tablespace.

Oracle Data Blocks At the finest level of granularity, Oracle database data is stored

in data blocks. One data block corresponds to a specific number of bytes of physical database space on disk. The standard block size is specified by the DB_BLOCK_SIZE initialization parameter.

Page 27: Introduction To Oracle

Logical Structures (cont’d)

Extents The next level of logical database space is an extent. An extent

is a specific number of contiguous data blocks, obtained in a single allocation, used to store a specific type of information.

Segments Above extents, the level of logical database storage is a

segment. A segment is a set of extents allocated for a certain logical structure. The different types of segments are : Data segment – stores table data Index segment – stores index data Temporary segment – temporary space used during SQL execution Rollback Segment – stores undo information

Page 28: Introduction To Oracle

Logical Structures (cont’d)

Schema Overview A schema is a collection of database objects. A schema

is owned by a database user and has the same name as that user. Schema objects are the logical structures that directly refer to the database's data. Schema objects include structures like tables, views, and indexes.

Page 29: Introduction To Oracle

Oracle Instance

An Oracle database server consists of an Oracle database and an Oracle instance. Every time a database is started, a system global area (SGA) is allocated and Oracle background processes are started. The combination of the background processes and memory buffers is called an Oracle instance.

Page 30: Introduction To Oracle

System Global Area (SGA)

The System Global Area (SGA) is a shared memory region that contains data and control information for one Oracle instance. Users currently connected to an Oracle database share the data in the SGA. The SGA contains the following memory structures :

Database Buffer Cache Database buffers store the most recently used blocks of

data. The set of database buffers in an instance is the database buffer cache. The buffer cache contains modified as well as unmodified blocks. Because the most recently (and often, the most frequently) used data is kept in memory, less disk I/O is necessary, and performance is improved.

Page 31: Introduction To Oracle

System Global Area (cont’d)

Redo Log Buffer of the SGA The redo log buffer stores redo entries—a log of changes made

to the database. The redo entries stored in the redo log buffers are written to an online redo log, which is used if database recovery is necessary. The size of the redo log is static.

Shared Pool of the SGA The shared pool contains shared memory constructs, such as

shared SQL areas. A shared SQL area is required to process every unique SQL statement submitted to a database. A shared SQL area contains information such as the parse tree and execution plan for the corresponding statement.

Page 32: Introduction To Oracle

Program Global Area (PGA)

PGA is a memory buffer that contains data and control information for a server process. A server process is a process that services a client’s requests. A PGA is created by oracle when a server process is started. The information in a PGA depends on the oracle configuration. The PGA area is a non-shared area of memory created by oracle when a server process is started.

The basic difference between SGA and PGA is that PGA cannot be shared between multiple processes in the sense that it is used only for requirements of a particular process whereas the SGA is used for the whole instance and it is shared.

Page 33: Introduction To Oracle

Oracle Background Processes

An Oracle database uses memory structures and processes to manage and access the database. All memory structures exist in the main memory of

the computers that constitute the database system. Processes are jobs that work in the memory of these computers.

Oracle creates a set of background processes for each instance. The background processes consolidate functions that would otherwise be

handled by multiple Oracle programs running for each user process. They asynchronously perform I/O and monitor other Oracle processes to provide

increased parallelism for better performance and reliability.

The most common background processes are:

System Monitor – SMONThis database background process performs instance recovery at the

start of the database. SMON also cleans up temporary segments that are no longer in use and recovers dead transactions skipped during crash and instance recovery because of file-read or offline errors. It

coalesces i.e. combines contiguous free extents into larger free extents.

Page 34: Introduction To Oracle

Background Processes (cont’d) Process Monitor - PMON

This database background process cleans up failed user processes. PMON is responsible for releasing the lock i.e. cleaning up the cache and freeing resources that the process was using. Its effect can be seen when a process holding a lock is killed.

Database Writer - DBWR This background process is responsible for managing the contents of

the data block buffer cache and dictionary cache. DBWR performs batch writes of changed block. Since Oracle uses write-ahead logging, DBWR does not need to write blocks when a transaction commits. In the most common case, DBWR writes only when more data needs to be read into the system global area and too few database buffers are free. The least recently used data is written to the datafiles first.

Although there is only one SMON and one PMON process running per database instance, one can have multiple DBWR processes running at the same time. Note the number of DBWR processes running is set via the DB_WRITER_PROCESSES.

Page 35: Introduction To Oracle

Background Processes (cont’d) Log Writer - LGWR

This background process manages the writing of the contents of the redo log buffer to the online redo log files. LGWR writes the log entries in batch form. The Redo log buffers entries always contain the most up-to-date status of the database.

Archiver - ARCH The Archiver process reads the redo log files once Oracle has filled

them and writes a copy of the used redo log files to the specified archive log destination(s). Actually, for most databases, ARCH has no effect on the overall system performance. On some large database sites, however, archiving can have an impact on system performance.

Page 36: Introduction To Oracle

Background Processes (cont’d) Checkpoint - CKPT

All modified information in database buffer in the SGA is written to the datafiles by a database write process (DBWR). This event indicates a checkpoint. The checkpoint process is responsible for signaling DBWR at checkpoints and updating all of the datafiles and control files of the database.

Recover - RECO The recover process automatically cleans up failed or suspended

distributed transactions.

Job Queue Processes Job queue processes are used for batch processing. They run user jobs.

They can be viewed as a scheduler service that can be used to schedule jobs as PL/SQL statements or procedures on an Oracle instance. Given a start date and an interval, the job queue processes try to run the job at the next occurrence of the interval.

Page 37: Introduction To Oracle

Computer Science Database

Server Information Sun e4500 8GB Ram 8 x 400mhz CPU 32GB Disk for

Oracle 4mm DAT DDS3

Tape Backup

Page 38: Introduction To Oracle

Computer Science Database

Instance Name : CS01 (v$database)Instance Version : 8.1.6.0.0Tablespaces : (dba_tablespaces)

SYSTEM – holds all system tablesINDEX01 – user indexesUSERS01 – user tablesUSERS02 – user tables (faculty)RBS – rollback segments

Page 39: Introduction To Oracle

Backup Methods

Cold Backup (aka Consistent Backups) The only way to make a consistent whole

database backup is to shut down the database with the NORMAL, IMMEDIATE, or TRANSACTIONAL options and make the backup while the database is closed.

Advantage : No recovery is required after datafiles are restored – quicker restore

Disadvantage : No access to database during backup time (depends on size/system speed)

Page 40: Introduction To Oracle

Backup Methods (cont’d)

Hot Backup (aka Inconsistent Backups) If the database must be up and running 24

hours a day, seven days a week, then you have no choice but to perform inconsistent backups of the whole database. A backup of online datafiles is called an online backup. This requires that you run your database in ARCHIVELOG mode.

Advantage : Database remains open during backup

Disadvantage : Large databases may have performance impact during backup, recovery takes longer and is slightly more complex

Page 41: Introduction To Oracle

Backup Methods (cont’d)

Logical backup (Export) Logical backups are exports of schema objects,

like tables and stored procedures, into a binary file. Oracle utilities are used to move Oracle schema objects in and out of Oracle.

Not recommended for backup of a whole database, but useful for backing up individual objects or schemas or moving data into another database

Page 42: Introduction To Oracle

Administrative Tasks

Daily Checks Check database availability Check logs / trace files Check free space / resources Check for invalid objects Check for broken jobs Verify backup

Page 43: Introduction To Oracle

Administrative Tasks (cont’d) Weekly Tasks

Collect statistics (database job) Archive / delete log files Run performance reports (statspack)

Page 44: Introduction To Oracle

Administrative Tasks (cont’d) Others

Applying patches Database upgrades New Database installations Creating user accounts

Page 45: Introduction To Oracle

More Information

Oracle 10g Release 2 Database Documentation http://www.oracle.com/pls/db102/

Oracle Database / SQL Help http://asktom.oracle.com/ http://www.oracle.com/technology//index.html

*FREE* Oracle Software Downloads http://www.oracle.com/technology/software/index.html

Oracle Database 10g Express Edition Oracle SQL Developer


Recommended