Fundamentals, Design, and Implementation, 9/e COS 346 DAY 20.

Slides:



Advertisements
Similar presentations
Fundamentals, Design, and Implementation, 9/e Chapter 8 Database Redesign.
Advertisements

Oracle Architecture. Instances and Databases (1/2)
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.
Introduction to Structured Query Language (SQL)
Database Administration Chapter Six DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 11.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 10-1 COS 346 Day 21.
Introduction to Structured Query Language (SQL)
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.
Prentice Hall © COS 346 Day Agenda Questions? Assignment 7 Corrected –4 A’s and 4 B’s Assignment 8 posted –Due April 6 Quiz 2 next class.
Backup The flip side of recovery. Types of Failures Transaction failure –Transaction must be aborted System failure –Hardware or software problem resulting.
Harvard University Oracle Database Administration Session 2 System Level.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 8-1 COS 346 Day 17.
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
Fundamentals, Design, and Implementation, 9/e Chapter 7 Using SQL in Applications.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 COS 346 Day 11.
Concepts of Database Management Sixth Edition
Introduction to Structured Query Language (SQL)
Database Administration Part 1 Chapter Six CSCI260 Database Applications.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
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.
Using SQL Queries to Insert, Update, Delete, and View Data © Abdou Illia MIS Spring 2015 Wednesday 1/28/2015 Chapter 3A.
Backup and Recovery Part 1.
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.
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 3 Administration of Users.
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.
Oracle Database Administration
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 13 Managing Databases with SQL Server 2000.
Oracle for Software Developers. What is a relational database? Data is represented as a set of two- dimensional tables. (rows and columns) One or more.
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.
Chapter 4 The Relational Model 3: Advanced Topics Concepts of Database Management Seventh Edition.
Database Technical Session By: Prof. Adarsh Patel.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
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.
Fundamentals, Design, and Implementation, 9/e Chapter 10 Managing Databases with Oracle 9i SII 654 Fall 2005.
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.
Introduction to the new mainframe © Copyright IBM Corp., All rights reserved. Chapter 12 Understanding database managers on z/OS.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
11 Copyright © 2004, Oracle. All rights reserved. Dealing with Database Corruption.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 12 Managing Databases with Oracle.
Fundamentals, Design, and Implementation, 9/e Chapter 8 Database Redesign.
Chapter 1Oracle9i DBA II: Backup/Recovery and Network Administration 1 Chapter 1 Backup and Recovery Overview MSCD642 Backup and Recovery.
Session 1 Module 1: Introduction to Data Integrity
Chapter 15: Reliability and Security in Database Servers Neyha Amar CS 157B May 6, 2008.
12 Copyright © Oracle Corporation, All rights reserved. User-Managed Complete Recovery.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Ten A: Managing Databases with Oracle Database.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
SQL Triggers, Functions & Stored Procedures Programming Operations.
 CONACT UC:  Magnific training   
6 Copyright © Oracle Corporation, All rights reserved. Backup and Recovery Overview.
Chapter Seven: SQL for Database Construction and Application Processing.
Getting started with Accurately Storing Data
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
Chapter 11 Managing Databases with SQL Server 2000
Presentation transcript:

Fundamentals, Design, and Implementation, 9/e COS 346 DAY 20

Fundamentals, Design, and Implementation, 9/e Chapter 10 Managing Databases with Oracle 9i

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/3 Copyright © 2004 Agenda  –  Quiz #3 Graded –Good Results 1 A, 3 B’s, 1 C and 1 D  Capstone Progress Reports Due  Assignment 9 Posted –Due April 12 –Two More to Go  Today Begin Discussion on Managing Databases with Oracle 9i

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/4 Copyright © 2004 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: Personal Oracle and Enterprise Oracle  Example of Oracle products –SQL*Plus: a utility for processing SQL and creating components like stored procedures and triggers PL/SQL is a programming language that adds programming constructs to the SQL language –Oracle Developer (Forms & Reports Builder) –Oracle Designer

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/5 Copyright © 2004 Creating an Oracle Database  Installing Oracle –Install Oracle 9i Client to use an already created database –Install Oracle 9i Personal Edition to create your own databases –Everyone has a theie own Oracle install “Name”_littleblack.umfk.maine.edu  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

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/6 Copyright © 2004 SQL*Plus  Oracle SQL*Plus or the Oracle Enterprise Manager Console may be used to manage an Oracle database  SQL*Plus is a text editor available in all Oracle –SQL*Plus Work Sheet is more powerful  Except inside quotation marks of strings, Oracle commands are case-insensitive  The semicolon (;) terminates a SQL statement  The right-leaning slash (/) executes SQL statement stored in Oracle buffer  SQL*Plus can be used to –Enter SQL statements –Submit SQL files created by text editors, e.g., notepad, to Oracle

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/7 Copyright © 2004 Example: SQL*Plus Prompt

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/8 Copyright © 2004 SQL*Plus Buffer  SQL*Plus keeps the current statements in a multi-line buffer without executing it  LIST is used to see the contents of the buffer –LIST [line_number] is used to change the current line  CHANGE/astring/bstring/ is used to change the contents of the current line –astring = the string you want to change –bstring = what you want to change it to  Example: change/Table_Name/*/ –‘Table_Name’ is replaced with ‘*’

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/9 Copyright © 2004 Example: SQL*Plus Buffer

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/10 Copyright © 2004 Creating Tables  Some of the SQL-92 CREATE TABLE statements need to be modified for Oracle –Oracle does not support a CASCADE UPDATE constraint –Int data type is interpreted by Oracle as Number(38) –Varchar data type is interpreted as VarChar2 –Money or currency is defined in Oracle using the Numeric data type  Oracle sequences must be used for surrogate keys  DESCRIBE or DESC command is used to view table status

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/11 Copyright © 2004 Oracle Data Types

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/12 Copyright © 2004 Oracle Sequences  A sequence is an object that generates a sequential series of unique numbers  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 value in the table

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/13 Copyright © 2004 Example: Sequences  Creating sequence CREATE SEQUENCE CustID INCREMENT BY 1 START WITH 1000;  Entering data using sequence INSERT INTO CUSTOMER (CustomerID, Name, AreaCode, PhoneNumber) VALUES (CustID.NextVal, ‘Mary Jones’, ‘350’, ‘555–1234);  Retrieving the row just created SELECT * FROM CUSTOMER WHERE CustomerID = CustID.CurrVal

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/14 Copyright © 2004 DROP and ALTER Statements  Drop statements may be used to remove structures from the database –DROP TABLE MYTABLE; Any data in the MYTABLE table will be lost –DROP SEQUENCE MySequence;  ALTER statement may be used to drop (add) a column –ALTER TABLE MYTABLE DROP COLUMN MyColumn; –ALTER TABLE MYTABLE ADD C1 NUMBER(4);

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/15 Copyright © 2004 TO_DATE Function  Oracle requires dates in a particular format  TO_DATE function may be used to identify the format –TO_DATE(‘11/12/2002’,’MM/DD/YYYY’) 11/12/2002 is the date value MM/DD/YYYY is the pattern to be used when interpreting the date  TO_DATE function can be used with the INSERT and UPDATE statement to enter data –INSERT INTO T1 VALUES (100, TO_DATE (‘01/05/02’, ‘DD/MM/YY’);

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/16 Copyright © 2004 Creating Indexes  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  Example: –CREATE INDEX CustNameIdx ON CUSTOMER(Name); –CREATE UNIQUE INDEX WorkUniqueIndex ON WORK(Title, Copy, ArtistID);

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/17 Copyright © 2004 Restrictions On Column Modifications  A column may be dropped at any time and all data will be lost  A column may be added at any time as long as it is a NULL column  To add a NOT NULL column –Add a NULL column –Fill the new column in every row with data –Change its structure to NOT NULL ALTER TABLE T1 MODIFY C1 NOT NULL;

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/18 Copyright © 2004 Creating Views  SQL-92 CREATE VIEW command can be used to create views in SQL*Plus  Oracle allows the ORDER BY clause in view definitions  Only Oracle 9i supports the JOIN…ON syntax  Example: CREATE VIEW CustomerInterests AS SELECT C.Name as Customer, A.Name as Artist FROM CUSTOMER C JOIN CUSTOMER_ARTIST_INT I ON C.CustomerID = I.CustomerID JOIN ARTIST A ON I.ArtistID = A.ArtistID;

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/19 Copyright © 2004 Working with Oracle  Project 1 on Page 373 –Uses files I provided in WebCT  Use SQL*Plus or SQL*Plus Work Sheet

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/20 Copyright © 2004 Day 20 Agenda  –  Capstone Progress Reports Over Due  Assignment 9 Posted –Due April 15 (date change) –Two More to Go  Today Discussion on Managing Databases with Oracle 9i

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/21 Copyright © 2004 Enterprise Manager Console  The Oracle Enterprise Manager Console provides graphical facilities for managing an Oracle database  The utility can be used to manage –Database structures such as tables and views –User accounts, passwords, roles, and privileges  The Manager Console includes a SQL scratchpad for executing SQL statements

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/22 Copyright © 2004 Application Logic  Oracle database application can be processed using –Programming language to invoke Oracle DBMS commands –Stored procedures –Start command to invoke database commands stored in.sql files –Triggers

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/23 Copyright © 2004 Stored Procedures  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  Execute or Exec command is used to invoke a stored procedure –Exec Customer_Insert (‘Michael Bench’, ‘203’, ‘ ’, ‘US’);

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/24 Copyright © 2004 Stored Procedure Example

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/25 Copyright © 2004 Example: Stored Procedure  IN signifies input parameters  OUT signifies an output parameter  IN OUT signifies a parameter used for both input and output  Variables are declared after the keyword AS

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/26 Copyright © 2004 Triggers  Oracle triggers are PL/SQL or Java procedures that are invoked when specified database activity occurs  Triggers can be used to –Enforce a business rule –Set complex default values –Update a view –Perform a referential integrity action –Handle exceptions

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/27 Copyright © 2004 Triggers (cont.)  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 a SQL command 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

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/28 Copyright © 2004 Day 21 Agenda  Assignment 9 Posted –Due April 15 (date change) –Two More to Go  Today Discussion on Managing Databases with Oracle 9i

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/29 Copyright © 2004 Oracle Name Resolution  TNSNAMES.ORA –Network Configuration File: “oracle install directory” \network\admin\tnsnames.ora –Generated by Oracle configuration tools. Enterprise Manager  For each connected database ROHAN_LITTLEBLACK.UMFK.MAINE.EDU = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = littleblack.umfk.maine.edu)(PORT = 1521)) ) (CONNECT_DATA = (SID = rohan) (SERVER = DEDICATED) )

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/30 Copyright © 2004 Data Dictionary  Oracle maintains a data dictionary of metadata  The metadata of the dictionary itself are stored in the table DICT SELECT Table_Name, Comments FROM DICT WHERE Table_Name LIKE (‘%TABLES%’);  USER_TABLES contains information about user or system tables DESC USER_TABLES;

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/31 Copyright © 2004 Example Oracle Metadata

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/32 Copyright © 2004 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 reads dirty data

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/33 Copyright © 2004 Oracle Transaction Isolation  Oracle supports the following transaction isolation levels –Read Committed: Oracle’s default transaction isolation level since it never reads uncommitted data changes –Serializable: Dirty reads are not possible, repeated reads yield the same results, and phantoms are not possible –Read Only: All statements read consistent data. No inserts, updates, or deletions are possible –Explicit locks: Not recommended

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/34 Copyright © 2004 How to set isolation level  SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;  ALTER SESSION SET ISOLATION_LEVEL SERIALIZABLE; START TRANACTION SET TRANACTION ISLOATION LEVEL READ ONLY IF ? COMMIT TRANASCTIONS ELSE ROLLBACK TRANASCTION ENDIF

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/35 Copyright © 2004 Oracle Security  Oracle security components: –An ACCOUNT is a user account –A PROFILE is a set of system resource maximums that are assigned to an account –A PRIVILEGE is the right to perform a task –A ROLE consists of groups of PRIVILEGEs and other ROLEs

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/36 Copyright © 2004 Account System Privileges  Each ACCOUNT can be allocated many SYSTEM PRIVILEGEs and many ROLEs  An 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 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

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/37 Copyright © 2004 Create Profile

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/38 Copyright © 2004 Add Privileges

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/39 Copyright © 2004 Add roles

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/40 Copyright © 2004 Account Authentication  Accounts can be authenticated by –Password –The host operating system Not recommended!  Password management can be specified via PROFILEs

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/41 Copyright © 2004 Create new user

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/42 Copyright © 2004 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

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/43 Copyright © 2004 Oracle Recovery Facilities (cont.)  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

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/44 Copyright © 2004 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

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/45 Copyright © 2004 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

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 10/46 Copyright © 2004 Oracle Backup

Fundamentals, Design, and Implementation, 9/e Chapter 10 Managing Databases with Oracle 9i