David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Ten A: Managing Databases with Oracle Database.

Slides:



Advertisements
Similar presentations
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 11-1 David M. Kroenke’s Chapter Eleven: Managing Databases with SQL Server.
Advertisements

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 9-1 COS 346 Day 20.
David M. Kroenke and David J. Auer Database Processing: F undamentals, Design, and Implementation Chapter Ten: Managing Databases with SQL Server 2008.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 10-1 COS 346 Day 21.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 COS 346 Day 11.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
Fundamentals, Design, and Implementation, 9/e Chapter 10 Managing Databases with Oracle 9i.
Getting Started (Excerpts) Chapter One DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 COS 346 Day 12.
Harvard University Oracle Database Administration Session 2 System Level.
Fundamentals, Design, and Implementation, 9/e Chapter 7 Using SQL in Applications.
Fundamentals, Design, and Implementation, 9/e Chapter 1 Introduction to Database Processing.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 COS 346 Day 11.
A Guide to SQL, Seventh Edition. Objectives Embed SQL commands in PL/SQL programs Retrieve single rows using embedded SQL Update a table using embedded.
David M. Kroenke and David J
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Getting Started with Microsoft SQL Server 2012 Express Edition Appendix A DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
David M. Kroenke and David J. Auer Database Processing—12 th Edition Fundamentals, Design, and Implementation Chapter One: Introduction KROENKE AND AUER.
Getting Started Chapter One DATABASE CONCEPTS, 7th Edition
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Getting Started with Microsoft Access The Access Workbench: Section One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
CHAPTER 16 User-Managed Backup and Recovery. Introduction to User Managed Backup and Recovery Backup and recover is one of the most critical skills a.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
Backup Concepts. Introduction Backup and recovery procedures protect your database against data loss and reconstruct the data, should loss occur. The.
Getting Started with Oracle Database 11g Release 2 Express Edition Appendix B DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 10-1 David M. Kroenke’s Chapter Ten: Managing Databases with Oracle Database.
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 13 Managing Databases with SQL Server 2000.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
INSERT BOOK COVER 1Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Microsoft Office Access 2010 by Robert Grauer, Keith.
Database Technical Session By: Prof. Adarsh Patel.
Backup & Recovery Backup and Recovery Strategies on Windows Server 2003.
David M. Kroenke and David J. Auer Database Processing: F undamentals, Design, and Implementation Chapter Six: Transforming Data Models into Database Designs.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
The protection of the DB against intentional or unintentional threats using computer-based or non- computer-based controls. Database Security – Part 2.
1 Oracle Architectural Components. 1-2 Objectives Listing the structures involved in connecting a user to an Oracle server Listing the stages in processing.
An Oracle server:  Is a database management system that provides an open, comprehensive, integrated approach to information management.  Consists.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
Fundamentals, Design, and Implementation, 9/e COS 346 DAY 20.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 12 Managing Databases with Oracle.
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Backup Concepts. Introduction Backup and recovery procedures protect your database against data loss and reconstruct the data, should loss occur. The.
David M. Kroenke and David J. Auer Database Processing: F undamentals, Design, and Implementation Chapter Seven: SQL for Database Construction and Application.
Chapter 1Oracle9i DBA II: Backup/Recovery and Network Administration 1 Chapter 1 Backup and Recovery Overview MSCD642 Backup and Recovery.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Seven: SQL for Database Construction and Application.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Eight: Database Redesign.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Ten A: Managing Databases with SQL Server 2012.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Six: Transforming Data Models into Database Designs.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Seven: SQL for Database Construction and Application.
CH 10 DB Application Design n 10.1 Functions n 10.2 Case Application n 10.3 Creating, Reading, Updating, Deleting View n 10.4 Form Design n 10.5 Report.
David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design, and Implementation Chapter Ten: Managing Databases with SQL Server 2012,
Chapter Seven: SQL for Database Construction and Application Processing.
A Guide to SQL, Seventh Edition
Transforming Data Models
David M. Kroenke and David J
PL/SQL Scripting in Oracle:
SQL for Database Construction and Application Processing
David M. Kroenke and David J
PT2520 Unit 9: Database Security II
Database Processing: David M. Kroenke’s Chapter Seven:
Database Processing: David M. Kroenke’s Chapter Seven:
Chapter 7 Using SQL in Applications
Contents Preface I Introduction Lesson Objectives I-2
Chapter 7 Using SQL in Applications
Getting Started Chapter One DATABASE CONCEPTS, 5th Edition
Chapter 11 Managing Databases with SQL Server 2000
Getting Started Chapter One DATABASE CONCEPTS, 4th Edition
Presentation transcript:

David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Ten A: Managing Databases with Oracle Database 11g KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-1

Chapter Objectives To install Oracle Database 11g and create a database To use Oracle Database 11g’s Web-based Database Control Enterprise Manager utility To use Oracle Database 11g’s graphical utilities To create and use Oracle Database 11g tablespaces To understand how Oracle Database 11g implements server and database security To submit both SQL DDL and DML via the SQL Developer KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-2

Chapter Objectives To understand the use of SQL/Persistent Stored Modules (SQL/PSM) in Oracle Database PL/SQL To understand the purpose and role of stored procedures and learn how to create simple stored procedures To understand the purpose and role of triggers and learn how to create simple triggers To understand how Oracle Database 11g implements concurrency control To understand the fundamental features of Oracle Database 11g backup and recovery facilities KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-3

Introduction Oracle is the world’s most popular DBMS—it is a powerful and robust DBMS that runs on many different operating systems. Oracle DBMS engine is available in several versions:versions –The Personal Edition of Oracle is available with this text and can also be downloaded from Oracle. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-4

View Ridge Gallery View Ridge Gallery is a small art gallery that has been in business for 30 years. It sells contemporary European and North American fine art. View Ridge Gallery has one owner, three salespeople, and two workers. View Ridge Gallery owns all of the art that it sells—it holds no items on a consignment basis. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-5

Application Requirements View Ridge Gallery application requirements –Track customers and their artist interests –Record gallery’s purchases –Record customers’ art purchases –List the artists and works that have appeared in the gallery –Report how fast an artist’s works have sold and at what margin –Show current inventory in a Webpage KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-6

View Ridge Gallery Database Design KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-7

The Loopback Adapter If you are installing Oracle Database 11g on a computer that gets an IP number from a DHCP server, you must install a lookback adapter before installing Oracle Database 11g. This is probably the case if your are installing a Personal (Developer) Edition on your own computer. Instructions for the Windows OS are in the Installation Guide for Microsoft Windows, Section Installation Guide for Microsoft Windows, Section KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-8

Creating an Oracle Database Three ways to create an Oracle database: –Via the Oracle Database Configuration Assistant –Via the Oracle-supplied database creation procedures –Via the SQL CREATE DATABASE command However, what we normally call a database is represented by a tablespace in Oracle. Oracle creates database instances which can hold many tablespaces. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-9

Creating an Oracle Database: The Oracle Database Configuration Assistant KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-10

Oracle Database 11g Administration For database administration, use the Web- based Enterprise Manager Database Control utility. For database development, use the GUI SQL Developer utility. Old Oracle hands may still prefer the text- based SQL*Plus utility. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-11

The Enterprise Manager Database Control I KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-12

The Enterprise Manager Database Control II KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-13

Tablespaces I KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-14

Tablespaces II KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-15

Tablespaces III KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-16

Tablespaces IV KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-17

Tablespaces V KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-18

Tablespaces VI KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-19

Oracle Security Oracle security components: –A USER is a user account. –A PROFILE is a set of system resource maximums that are assigned to an account. –A SYSTEM PRIVILEGE is the right to perform a task. –An OBJECT PRIVILEGE is the right to work with that object. –A ROLE consists of groups of PRIVILEGEs and other ROLEs. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-20

USER System Privileges Each USER can be allocated many SYSTEM PRIVILEGEs, OBJECT PRIVILEGEs and ROLEs. A USER account has all the PRIVILEGEs: –That have been assigned directly –Of all of its ROLEs –Of all of its ROLEs that are inherited through ROLE connections A ROLE can have many SYSTEM PRIVILEGEs and OBJECT PRIVILEGEs, and it may also have a relationship to other ROLEs. ROLEs simplify the administration of the database: –A set of privileges can be assigned to or removed from a ROLE just once. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-21

Users, Roles, and Privileges I KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-22

Users, Roles, and Privileges II KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-23

Users, Roles, and Privileges III KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-24

Users, Roles, and Privileges IV KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-25

Users, Roles, and Privileges V KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-26

Users, Roles, and Privileges VI KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-27

Users, Roles, and Privileges VII KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-28

Users, Roles, and Privileges VIII KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-29

Users, Roles, and Privileges IX KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-30

Oracle Application Development Utilities Oracle SQL*Plus or the Oracle SQL Developer Console may be used for application development. SQL*Plus is a text editor. SQL Developer is a GUI utility. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-31

SQL*Plus KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-32

SQL Developer I KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-33

SQL Developer II KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-34

SQL Scripts I KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-35

SQL Scripts II KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-36

Oracle CREATE TABLE Statements for the View Ridge Schema I KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-37

Oracle CREATE TABLE Statements for the View Ridge Schema II KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-38

Oracle CREATE TABLE Statements for the View Ridge Schema III KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-39

Oracle CREATE TABLE Statements for the View Ridge Schema IV KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-40

Oracle CREATE TABLE Statements for the View Ridge Schema V KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-41

Inspecting Table Properties I KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-42

Inspecting Table Properties II KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-43

Inspecting Table Properties III KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-44

Inspecting Table Properties IV KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-45

Inspecting Table Properties V KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-46

Creating Indexes I Indexes are created to: –Enforce uniqueness on columns –Facilitate sorting –Enable fast retrieval by column values Good candidates for indexes are columns that are frequently used with equal conditions in WHERE clause or in a join. Examples: CREATE INDEX CustNameIdx ON CUSTOMER(Name); CREATE UNIQUE INDEX WorkUniqueIndex ON WORK(Title, Copy, ArtistID); KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-47

Creating Indexes II KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-48

Creating Indexes III KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-49

Oracle Sequences A sequence is an object that generates a sequential series of unique numbers. Create Sequence CustID Increment by 1 start with 1000; It is the best way to work with surrogate keys in Oracle. Two sequence methods: –NextVal provides the next value in a sequence. –CurrVal provides the current value in a sequence. Using sequences does not guarantee valid surrogate key values because it is possible to have missing, duplicate, or wrong sequence values in the table. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-50

Using Sequences Creating a sequence: CREATE SEQUENCE seqCID INCREMENT BY 1 START WITH 1000; Entering data using a sequence: INSERT INTO CUSTOMER (CustomerID, Name, AreaCode, PhoneNumber) VALUES( seqCID.NextVal, 'Mary Jones', '350', '555–1234'); Retrieving the row just created: SELECT * FROM CUSTOMER WHERE CustomerID = seqCID.CurrVal; KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-51

The TO_DATE Function Oracle requires dates in a particular format. TO_DATE function may be used to identify the format: TO_DATE('11/12/2011', 'MM/DD/YYYY') 11/12/2011 is the date value. MM/DD/YYYY is the pattern to be used when interpreting the date. The TO_DATE function can be used with the INSERT and UPDATE statements to enter data: INSERT INTO T1 VALUES( 100, TO_DATE ('01/05/2011', 'DD/MM/YYYY'); KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-52

Creating Views I The CREATE VIEW statement can be used to create views in Oracle. Unlike SQL-92, Oracle allows the ORDER BY clause in view definitions. Oracle supports the JOIN…ON syntax. Example: CREATE VIEW CustomerInterests AS SELECT C.LastName AS CustomerLastName, C.FirstName AS CustomerFirstName, A.LastName AS ArtistName FROM CUSTOMER C JOIN CUSTOMER_ARTIST_INT CAI ON C.CustomerID = CAI.CustomerID JOIN ARTIST A ON CAI.ArtistID = A.ArtistID; KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-53

Creating Views II KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-54

Application Logic I Oracle Database implements the SQL/Persistent Stored Modules (SQL/PSM) standard in the Oracle Database Procedural Language/SQL (PL/SQL). Oracle Database also supports the use of the Java programming language for writing Oracle Database functions, stored procedures and triggers. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-55

Application Logic II Oracle database applications can be processed using: –Programming languages to invoke DBMS commands –The SQL*Plus Command Line utility to invoke database commands stored in.sql files –The SQL Developer to invoke database commands stored in.sql files –Stored procedures –Triggers KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-56

Application Logic: Parameters and Variables A parameter is a value passed to a stored procedure. A variable is a value used within the stored procedure. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-57

Application Logic: Oracle Block Structure Oracle blocks must end with a single slash (/) as a signal to compile and execute the code to create the procedure or trigger: This is a slash (/) KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-58

Application Logic: Oracle Control of Flow Statements I IF…THEN…ELSE…END IF IF…ELSIF…END IF KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-59

Application Logic: Oracle Control of Flow Statements II BEGIN…END RETURN KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-60

Application Logic: Oracle Cursor Statements DECLARE OPEN FETCH LOOP FOR WHILE EXIT WHEN CLOSE KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-61

Application Logic: Oracle Output Statements Oracle uses the DBMS_OUTPUT.PUT_LINE ({text here}) statement for output. To use this statement, you must first execute: SET SERVEROUT ON KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-62

Stored Procedures I A stored procedure is a PL/SQL or Java program stored within the database. Stored procedures are programs that can: –Have parameters –Invoke other procedures and functions –Return values –Raise exceptions A stored procedure must be compiled and stored in the database. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-63

Stored Procedures I The CALL command is used to invoke a stored procedure: SET SERVEROUTPUT ON CALL InsertCustomerAndInterests ( ' Bench ', 'Michael', ' 206 ', ‘ ', ', 'French ' ); KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-64

KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-65

KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-66

Running Stored Procedures KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-67

Triggers An Oracle trigger is a PL/SQL or Java procedure that is invoked when a specified database activity occurs. Triggers can be used to: –Set default values –Enforce a Data Constraint –Update a view –Enforce referential integrity action –Handle exceptions KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-68

Triggers Trigger types: –A command trigger will be fired once per SQL command. –A row trigger will be fired once for every row involved in the processing of an SQL command. There are three types of row triggers: BEFORE, AFTER, and INSTEAD OF. BEFORE and AFTER triggers are placed on tables while INSTEAD OF triggers are placed on views. Each trigger can be fired on INSERT, UPDATE, or DELETE commands. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-69

KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-70

Running Triggers KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-71

Triggers Comparison KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-72

Concurrency Control Oracle processes database changes by maintaining a System Change Number (SCN). –SCN is a database-wide value that is incremented by Oracle when database changes are made. With SCN, SQL statements always read a consistent set of values; those that were committed at or before the time the statement was started. Oracle only reads committed changes; it will never read dirty data. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-73

Oracle Transaction Isolation KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-74

Oracle Recovery Facilities Three file types for Oracle recovery: –Datafiles contain user and system data. –ReDo log files contain logs of database changes. Online ReDo files are maintained on disk and contain the rollback segments from recent database changes. Offline or Archive ReDo files are backups of the Online ReDo files. –Control files describe the name, contents, and locations of various files used by Oracle. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-75

Oracle Recovery Facilities Oracle can operate in either ARCHIVELOG or NOARCHIVELOG mode: –If running in ARCHIVELOG mode, Oracle logs all changes to the database. –When the Online ReDo files fill up, they are copied to the Archive ReDo files. The Oracle Recovery Manager (RMAN) is a utility program used to create backups and to perform recovery. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-76

Types of Failure Oracle recovery techniques depend on the type of failure: –An application failure due to application logic errors. –An instance failure occurs when Oracle itself fails due to an operating system or computer hardware failure. Oracle can recover from application and instance failure without using the archived log file. –A media failure occurs when Oracle is unable to write to a physical file because of a disk failure or corrupted files. The database is restored from a backup. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-77

Oracle Backup Facilities Two kinds of backups: –A consistent backup: database activity must be stopped and all uncommitted changes have been removed from the datafiles Cannot be done if the database supports 24/7 operations. –An inconsistent backup: backup is made while Oracle is processing the database An inconsistent backup can be made consistent by processing an archive log file. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-78

David Kroenke and David Auer Database Processing Fundamentals, Design, and Implementation (12th Edition) End of Presentation: Chapter Ten A KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-79

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America. Copyright © 2012 Pearson Education, Inc. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall 10A-80