0% found this document useful (0 votes)
50 views49 pages

TOC - 19c SQL, DB Admin, Backup & Recovery and Multitenant Architecture

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views49 pages

TOC - 19c SQL, DB Admin, Backup & Recovery and Multitenant Architecture

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Oracle Database 19c: SQL Workshop (5 Days – 40 Hours)

Contents

1 Introduction
Lesson Objectives 1-2
Lesson Agenda 1-3
Course Objectives 1-4
Icons Used in This Course 1-5
Course Roadmap 1-6
Appendixes and Practices Used in the Course 1-13
Lesson Agenda 1-14
Oracle Database 19c: Focus Areas 1-15
Oracle Database 19c 1-16
MySQL: A Modern Database for the Digital Age 1-18
High Scalability with MySQL 1-19
MySQL-Supported Operating Systems 1-20
MySQL Enterprise Edition 1-21
Why MySQL Enterprise Edition? 1-22
Oracle Premier Support for MySQL 1-23
MySQL and Oracle Integration 1-24
Lesson Agenda 1-25
Relational and Object Relational Database Management Systems 1-26
Data Storage on Different Media 1-27
Relational Database Concept 1-28
Definition of a Relational Database 1-29
Data Models 1-30
Entity Relationship Model 1-31
Entity Relationship Modeling Conventions 1-32
Relating Multiple Tables 1-34
Relational Database Terminology 1-35
Lesson Agenda 1-36
Human Resources (HR) Application 1-37
Tables Used in This Course 1-38
Tables Used in the Course 1-39
Lesson Agenda 1-40
Using SQL to Query Your Database 1-41
How SQL Works 1-42
SQL Statements Used in the Course 1-43
Development Environments for SQL in Oracle 1-44
Introduction to Oracle Live SQL 1-45
Development Environments for SQL in MySQL 1-46
Lesson Agenda 1-47
Oracle Database Documentation 1-48
Additional Resources for Oracle 1-49
Oracle University: Oracle SQL Training 1-50
Oracle SQL Certification 1-51
MySQL Websites 1-52
MySQL Community Resources 1-53
Oracle University: MySQL Training 1-54
MySQL Certification 1-55
Summary 1-56
Practice 1: Overview 1-57

2 Retrieving Data Using the SQL SELECT Statement


Course Roadmap 2-2
Objectives 2-3
Lesson Agenda 2-4
HR Application Scenario 2-5
Writing SQL Statements 2-6
Basic SELECT Statement 2-7
Selecting All Columns 2-8
Executing SQL Statements with Oracle SQL Developer and SQL*Plus 2-9
Column Heading Defaults in SQL Developer and SQL*Plus 2-10
Executing SQL Statements in MySQL Workbench 2-11
Executing SQL Statements in mysql Command-line Client 2-12
Selecting Specific Columns 2-13
Selecting from dual with Oracle Database 2-14
Selecting Constant Expressions in MySQL 2-15
Lesson Agenda 2-16
Arithmetic Expressions 2-17
Using Arithmetic Operators 2-18
Operator Precedence 2-19
Defining a Null Value 2-20
Null Values in Arithmetic Expressions 2-21
Lesson Agenda 2-22
Defining a Column Alias 2-23
Using Column Aliases 2-24
Lesson Agenda 2-25
Concatenation Operator in Oracle 2-26
Concatenation Function in MySQL – CONCAT() 2-27
Literal Character Strings 2-28
Using Literal Character Strings in Oracle 2-29
Using Literal Character Strings in MySQL 2-30
Alternative Quote (q) Operator in Oracle 2-31
Including a Single Quotation Mark in a String with an Escape Sequence
in MySQL 2-32
Duplicate Rows 2-33
Lesson Agenda 2-34
Displaying Table Structure by Using the DESCRIBE Command 2-35
Displaying Table Structure by Using Oracle SQL Developer 2-36
Displaying Table Structure by Using MySQL Workbench 2-37
Summary 2-38
Practice 2: Overview 2-39

3 Restricting and Sorting Data


Course Roadmap 3-2
Objectives 3-3
Lesson Agenda 3-4
Limiting Rows by Using a Selection 3-5
Limiting Rows That Are Selected 3-6
Using the WHERE Clause 3-7
Character Strings and Dates 3-8
Comparison Operators 3-9
Using Comparison Operators 3-10
Range Conditions Using the BETWEEN Operator 3-11
Using the IN Operator 3-12
Pattern Matching Using the LIKE Operator 3-13
Combining Wildcard Symbols 3-14
Using NULL Conditions 3-15
Defining Conditions Using Logical Operators 3-16
Using the AND Operator 3-17
Using the OR Operator 3-18
Using the NOT Operator 3-19
Lesson Agenda 3-20
Rules of Precedence 3-21
Lesson Agenda 3-23
Using the ORDER BY Clause 3-24
Sorting 3-25
Lesson Agenda 3-27
SQL Row Limiting Clause 3-28
Using SQL Row Limiting Clause in a Query in Oracle 3-29
SQL Row Limiting Clause: Example in Oracle 3-30
Using SQL Row Limiting Clause in a Query in MySQL 3-31
SQL Row Limiting Clause: Example in MySQL 3-32
Lesson Agenda 3-33
Substitution Variables in Oracle 3-34
Using the Single-Ampersand Substitution Variable 3-36
Character and Date Values with Substitution Variables 3-38
Specifying Column Names, Expressions, and Text 3-39
Using the Double-Ampersand Substitution Variable 3-40
Using the Ampersand Substitution Variable in SQL*Plus 3-41
Lesson Agenda 3-42
Using the DEFINE Command in Oracle 3-43
Using the VERIFY Command in Oracle 3-44
Using the SET Statement in MySQL 3-45
Summary 3-46
Practice 3: Overview 3-47

4 Using Single-Row Functions to Customize Output


Course Roadmap 4-2
Objectives 4-3
HR Application Scenario 4-4
Lesson Agenda 4-5
SQL Functions 4-6
Two Types of SQL Functions 4-7
Single-Row Functions 4-8
Lesson Agenda 4-10
Character Functions 4-11
Case-Conversion Functions 4-13
Using Case-Conversion Functions in WHERE Clauses in Oracle 4-14
Case-Insensitive Queries in MySQL 4-15
Character-Manipulation Functions 4-16
Using Character-Manipulation Functions 4-17
Lesson Agenda 4-18
Nesting Functions 4-19
Nesting Functions: Example 4-20
Lesson Agenda 4-21
Numeric Functions 4-22
Using the ROUND Function 4-23
Using the TRUNC Function in Oracle 4-24
Using the TRUNCATE Function in MySQL 4-25
Using the MOD Function 4-26
Lesson Agenda 4-27
Working with Dates in Oracle Databases 4-28
RR Date Format in Oracle 4-29
Using the SYSDATE Function in Oracle 4-30
Using the CURRENT_DATE and CURRENT_TIMESTAMP Functions
in Oracle 4-31
Arithmetic with Dates in Oracle 4-32
Using Arithmetic Operators with Dates in Oracle 4-33
Lesson Agenda 4-34
Working with Dates in MySQL Databases 4-35
Displaying the Current Date in MySQL 4-36
Lesson Agenda 4-37
Date-Manipulation Functions in Oracle 4-38
Using Date Functions in Oracle 4-39
Using ROUND and TRUNC Functions with Dates in Oracle 4-40
Date-Manipulation Functions in MySQL 4-41
Using Date Functions in MySQL 4-42
Extracting the Month or Year Portion of Dates in MySQL 4-43
Summary 4-44
Practice 4: Overview 4-45

5 Using Conversion Functions and Conditional Expressions


Course Roadmap 5-2
Objectives 5-3
Lesson Agenda 5-4
Conversion Functions 5-5
Implicit Data Type Conversion of Strings to Numbers 5-6
Implicit Data Type Conversion of Numbers to Strings 5-7
Lesson Agenda 5-8
Using the TO_CHAR Function with Dates 5-9
Elements of the Date Format Model 5-10
Using the TO_CHAR Function with Dates 5-13
Using the TO_CHAR Function with Numbers 5-14
Using the TO_NUMBER and TO_DATE Functions 5-17
Using TO_CHAR and TO_DATE Functions with the RR Date Format 5-19
Lesson Agenda 5-20
Using the CAST() function in Oracle 5-21
Explicit Data Type Conversion of Strings to Numbers in MySQL 5-22
Explicit Data Type Conversion of Numbers to Strings in MySQL 5-23
Lesson Agenda 5-24
General Functions 5-25
NVL Function (Oracle) and IFNULL() Function (MySQL) 5-26
Using the NVL Function in Oracle 5-27
Using the NVL2 Function in Oracle 5-28
Using the IFNULL Function in MySQL 5-29
Using the NULLIF Function 5-30
Using the COALESCE Function 5-31
Lesson Agenda 5-33
Conditional Expressions 5-34
CASE Expression 5-35
Using the CASE Expression 5-36
Searched CASE Expression 5-37
DECODE Function in Oracle 5-38
Using the DECODE Function 5-39
Lesson Agenda 5-41
JSON_QUERY Function 5-42
JSON_TABLE Function 5-43
JSON_VALUE Function 5-44
Summary 5-45
Practice 5: Overview 5-46

6 Reporting Aggregated Data Using the Group Functions


Course Roadmap 6-2
Objectives 6-3
Lesson Agenda 6-4
Group Functions 6-5
Types of Group Functions 6-6
Group Functions: Syntax 6-7
Using the AVG and SUM Functions 6-8
Using the MIN and MAX Functions 6-9
Using the COUNT Function 6-10
Using the DISTINCT Keyword 6-11
Group Functions and Null Values in Oracle 6-12
Group Functions and Null Values in MySQL 6-13
Lesson Agenda 6-14
Creating Groups of Data 6-15
Creating Groups of Data: GROUP BY Clause Syntax 6-16
Using the GROUP BY Clause 6-17
Grouping by More Than One Column 6-19
Using the GROUP BY Clause on Multiple Columns 6-20
Illegal Queries Using Group Functions 6-21
Illegal Queries Using Group Functions in a WHERE Clause 6-22
Restricting Group Results 6-23
Restricting Group Results with the HAVING Clause 6-24
Using the HAVING Clause 6-25
Lesson Agenda 6-27
Nesting Group Functions in Oracle 6-28
Summary 6-29
Practice 6: Overview 6-30

7 Displaying Data from Multiple Tables Using Joins


Course Roadmap 7-2
Objectives 7-3
Lesson Agenda 7-4
Why Join? 7-5
Obtaining Data from Multiple Tables 7-6
Types of Joins 7-7
Joining Tables Using SQL Syntax 7-8
Lesson Agenda 7-9
Creating Natural Joins 7-10
Retrieving Records with Natural Joins 7-11
Creating Joins with the USING Clause 7-12
Joining Column Names 7-13
Retrieving Records with the USING Clause 7-14
Qualifying Ambiguous Column Names 7-15
Using Table Aliases with the USING Clause in Oracle 7-16
Creating Joins with the ON Clause 7-17
Retrieving Records with the ON Clause 7-18
Creating Three-Way Joins 7-19
Applying Additional Conditions to a Join 7-20
Lesson Agenda 7-21
Joining a Table to Itself 7-22
Self-Joins Using the ON Clause 7-23
Lesson Agenda 7-24
Nonequijoins 7-25
Retrieving Records with Nonequijoins 7-26
Lesson Agenda 7-27
Returning Records with No Direct Match Using OUTER Joins 7-28
INNER Versus OUTER Joins 7-29
LEFT OUTER JOIN 7-30
RIGHT OUTER JOIN 7-31
FULL OUTER JOIN in Oracle 7-32
Lesson Agenda 7-33
Cartesian Products 7-34
Generating a Cartesian Product 7-35
Creating Cross Joins 7-36
Summary 7-37
Practice 7: Overview 7-38

8 Using Subqueries to Solve Queries


Course Roadmap 8-2
Objectives 8-3
Lesson Agenda 8-4
Using a Subquery to Solve a Problem 8-5
Subquery Syntax 8-6
Using a Subquery 8-7
Rules and Guidelines for Using Subqueries 8-8
Types of Subqueries 8-9
Lesson Agenda 8-10
Single-Row Subqueries 8-11
Executing Single-Row Subqueries 8-12
Using Group Functions in a Subquery 8-13
HAVING Clause with Subqueries 8-14
What Is Wrong with This Statement? 8-15
No Rows Returned by the Inner Query 8-16
Lesson Agenda 8-17
Multiple-Row Subqueries 8-18
Using the ANY Operator in Multiple-Row Subqueries 8-19
Using the ALL Operator in Multiple-Row Subqueries 8-20
Multiple-Column Subqueries 8-21
Multiple-Column Subquery: Example 8-22
Lesson Agenda 8-23
Null Values in a Subquery 8-24
Summary 8-25
Practice 8: Overview 8-26

9 Using Set Operators


Course Roadmap 9-2
Objectives 9-3
Lesson Agenda 9-4
Set Operators 9-5
Set Operator Rules 9-6
Oracle Server and Set Operators 9-7
Lesson Agenda 9-8
Tables Used in This Lesson 9-9
Lesson Agenda 9-13
UNION Operator 9-14
Using the UNION Operator 9-15
UNION ALL Operator 9-16
Using the UNION ALL Operator 9-17
Lesson Agenda 9-18
Matching the SELECT Statement: Example in Oracle 9-26
Matching SELECT Statements in MySQL 9-27
Matching the SELECT Statement: Example in MySQL 9-28
Lesson Agenda 9-29
Using the ORDER BY Clause with UNION in MySQL 9-32
Using the ORDER BY Clause with UNION: Example in MySQL 9-33
Summary 9-34
Practice 9: Overview 9-35

10a Managing Tables Using DML Statements in Oracle


Course Roadmap 10a-2
Objectives 10a-3
HR Application Scenario 10a-4
Lesson Agenda 10a-5
Data Manipulation Language 10a-6
Adding a New Row to a Table 10a-7
INSERT Statement Syntax 10a-8
Inserting New Rows 10a-9
Inserting Rows with Null Values 10a-10
Inserting Special Values 10a-11
Inserting Specific Date and Time Values 10a-12
Creating a Script 10a-13
Copying Rows from Another Table 10a-14
Lesson Agenda 10a-15
Changing Data in a Table 10a-16
UPDATE Statement Syntax 10a-17
Updating Rows in a Table 10a-18
Updating Two Columns with a Subquery 10a-19
Updating Rows Based on Another Table 10a-20
Lesson Agenda 10a-21
Removing a Row from a Table 10a-22
DELETE Statement 10a-23
Deleting Rows from a Table 10a-24
Deleting Rows Based on Another Table 10a-25
TRUNCATE Statement 10a-26
Lesson Agenda 10a-27
Database Transactions 10a-28
Database Transactions: Start and End 10a-29
Advantages of the COMMIT and ROLLBACK Statements 10a-30
Explicit Transaction Control Statements 10a-31
Rolling Back Changes to a Marker 10a-32
Implicit Transaction Processing 10a-33
State of Data Before COMMIT or ROLLBACK 10a-34
State of Data After COMMIT 10a-35
Committing Data 10a-36
State of Data After ROLLBACK 10a-37
State of Data After ROLLBACK: Example 10a-38
Statement-Level Rollback 10a-39
Lesson Agenda 10a-40
Read Consistency 10a-41
Implementing Read Consistency 10a-42
Lesson Agenda 10a-43
FOR UPDATE Clause in a SELECT Statement 10a-44
FOR UPDATE Clause: Examples 10a-45
LOCK TABLE Statement 10a-46
Summary 10a-47
Practice 10a: Overview 10a-48

10b Managing Tables Using DML Statements in MySQL


Course Roadmap 10b-2
Objectives 10b-3
HR Application Scenario 10b-4
Lesson Agenda 10b-5
Data Manipulation Language 10b-6
Adding a New Row to a Table 10b-7
INSERT Statement Syntax 10b-8
Inserting New Rows: Listing Column Names 10b-9
Inserting New Rows: Omitting Column Names 10b-10
Inserting Rows with Null Values 10b-11
Inserting Special Values in MySQL 10b-12
Inserting Specific Date and Time Values in MySQL 10b-13
Inserting and Reformatting Specific Date and Time Values in MySQL 10b-14
Copying Rows from Another Table 10b-15
Lesson Agenda 10b-16
Changing Data in a Table 10b-17
UPDATE Statement Syntax 10b-18
Updating Rows in a Table 10b-19
Updating Rows Based on Another Table 10b-20
Quiz 10b-21
Lesson Agenda 10b-22
Removing a Row from a Table 10b-23
DELETE Statement 10b-24
Deleting Rows from a Table 10b-25
Deleting Rows Based on Another Table 10b-26
TRUNCATE Statement 10b-27
Lesson Agenda 10b-28
Multiple-statement Transactions 10b-29
Transaction Diagram 10b-30
AUTOCOMMIT and Transaction Control Statements 10b-31
Committing Data in a Transaction 10b-32
Rolling Back Changes 10b-33
Rolling Back Changes to a Marker 10b-34
Lesson Agenda 10b-35
Consistent Reads 10b-36
Lesson Agenda 10b-37
FOR UPDATE Clause in a SELECT Statement 10b-38
FOR UPDATE Clause: Examples 10b-39
Summary 10b-40
Practice 10b: Overview 10b-41

11a Introduction to Data Definition Language in Oracle


Course Roadmap 11a-2
Objectives 11a-3
HR Application Scenario 11a-4
Lesson Agenda 11a-5
Database Objects 11a-6
Naming Rules for Tables and Columns 11a-7
Lesson Agenda 11a-8
CREATE TABLE Statement 11a-9
Creating Tables 11a-10
Lesson Agenda 11a-11
Data Types 11a-12
Datetime Data Types 11a-14
DEFAULT Option 11a-15
Lesson Agenda 11a-16
Including Constraints 11a-17
Constraint Guidelines 11a-18
Defining Constraints 11a-19
Defining Constraints: Example 11a-20
NOT NULL Constraint 11a-21
UNIQUE Constraint 11a-22
PRIMARY KEY Constraint 11a-24
FOREIGN KEY Constraint 11a-25
FOREIGN KEY Constraint: Keywords 11a-27
CHECK Constraint 11a-28
CREATE TABLE: Example 11a-29
Violating Constraints 11a-30
Lesson Agenda 11a-32
Creating a Table Using a Subquery 11a-33
Lesson Agenda 11a-35
ALTER TABLE Statement 11a-36
Adding a Column 11a-38
Modifying a Column 11a-39
Dropping a Column 11a-40
SET UNUSED Option 11a-41
Read-Only Tables 11a-43
Lesson Agenda 11a-44
Dropping a Table 11a-45
Summary 11a-46
Practice 11a: Overview 11a-47

11b Introduction to Data Definition Language in MySQL


Course Roadmap 11b-2
Objectives 11b-3
HR Application Scenario 11b-4
Lesson Agenda 11b-5
Creating a Database: Syntax 11b-6
MySQL Naming Conventions 11b-7
Lesson Agenda 11b-8
CREATE TABLE Statement 11b-9
Lesson Agenda 11b-10
Data Types: Overview 11b-11
Numeric Data Types 11b-12
Date and Time Data Types 11b-13
String Data Types 11b-14
Lesson Agenda 11b-15
Indexes, Keys, and Constraints 11b-16
Table Indexes 11b-17
Primary Keys 11b-18
Unique Key Constraints 11b-19
Foreign Key Constraints 11b-20
Foreign Key Constraint: Example Tables 11b-21
FOREIGN KEY Constraint: Example Statement 11b-22
FOREIGN KEY Constraint: Referential Actions 11b-23
Secondary Indexes 11b-24
Lesson Agenda 11b-25
Column Options 11b-26
Lesson Agenda 11b-27
Creating a Table Using a Subquery 11b-28
Creating a Table Using a Subquery: Example 11b-29
Lesson Agenda 11b-30
ALTER TABLE Statement 11b-31
ALTER TABLE Statement: Add, Modify, or Drop Columns 11b-32
Adding a Column 11b-33
Modifying a Column 11b-34
Dropping a Column 11b-35
ALTER TABLE Statement: Add an Index or Constraint 11b-36
ALTER TABLE to Add a Constraint or Index: Example 11b-37
Creating Indexes by Using the CREATE INDEX Statement 11b-38
Viewing Index Definitions by Using the SHOW INDEX Statement 11b-39
Showing How a Table Was Created with the SHOW CREATE
TABLE Statement 11b-40
Lesson Agenda 11b-41
Dropping a Table 11b-42
Summary 11b-43
Practice 11b: Overview 11b-44

12 Introduction to Data Dictionary Views


Course Roadmap 12-2
Objectives 12-3
Lesson Agenda 12-4
Why Data Dictionary? 12-5
Data Dictionary 12-6
Data Dictionary Structure 12-7
How to Use Dictionary Views 12-9
USER_OBJECTS and ALL_OBJECTS Views 12-10
USER_OBJECTS View 12-11
Lesson Agenda 12-12
Table Information 12-13
Column Information 12-14
Constraint Information 12-16
USER_CONSTRAINTS: Example 12-17
Querying USER_CONS_COLUMNS 12-18
Lesson Agenda 12-19
Adding Comments to a Table 12-20
Summary 12-21
Practice 12: Overview 12-22

13 Creating Sequences, Synonyms, and Indexes


Course Roadmap 13-2
Objectives 13-3
Lesson Agenda 13-4
E-Commerce Scenario 13-5
Database Objects 13-6
Referencing Another User’s Tables 13-7
Sequences 13-8
CREATE SEQUENCE Statement: Syntax 13-9
Creating a Sequence 13-11
NEXTVAL and CURRVAL Pseudocolumns 13-12
Using a Sequence 13-14
SQL Column Defaulting Using a Sequence 13-15
Caching Sequence Values 13-16
Modifying a Sequence 13-17
Guidelines for Modifying a Sequence 13-18
Sequence Information 13-19
Lesson Agenda 13-20
Synonyms 13-21
Creating a Synonym for an Object 13-22
Creating and Removing Synonyms 13-23
Synonym Information 13-24
Lesson Agenda 13-25
Indexes 13-26
How Are Indexes Created? 13-27
Creating an Index 13-28
CREATE INDEX with the CREATE TABLE Statement 13-29
Function-Based Indexes 13-31
Creating Multiple Indexes on the Same Set of Columns 13-32
Creating Multiple Indexes on the Same Set of Columns: Example 13-33
Index Information 13-34
USER_INDEXES: Examples 13-35
Querying USER_IND_COLUMNS 13-36
Removing an Index 13-37
Summary 13-38
Practice 13: Overview 13-39

14 Creating Views
Course Roadmap 14-2
Objectives 14-3
Lesson Agenda 14-4
Why Views? 14-5
Database Objects 14-6
What Is a View? 14-7
Advantages of Views 14-8
Simple Views and Complex Views 14-9
Lesson Agenda 14-10
Creating a View 14-11
Retrieving Data from a View 14-14
Modifying a View 14-15
Creating a Complex View 14-16
View Information 14-17
Lesson Agenda 14-18
Rules for Performing DML Operations on a View 14-19
Rules for Performing Modify Operations on a View 14-20
Rules for Performing Insert Operations Through a View 14-21
Using the WITH CHECK OPTION Clause 14-22
Denying DML Operations 14-23
Lesson Agenda 14-25
Removing a View 14-26
Summary 14-27
Practice 14: Overview 14-28

15 Managing Schema Objects


Course Roadmap 15-2
Objectives 15-3
Lesson Agenda 15-4
Adding a Constraint Syntax 15-5
Adding a Constraint 15-6
Dropping a Constraint 15-7
Dropping a Constraint ONLINE 15-8
ON DELETE Clause 15-9
Cascading Constraints 15-10
Renaming Table Columns and Constraints 15-12
Disabling Constraints 15-13
Enabling Constraints 15-14
Constraint States 15-15
Deferring Constraints 15-16
Difference Between INITIALLY DEFERRED and INITIALLY IMMEDIATE 15-17
DROP TABLE … PURGE 15-19
Lesson Agenda 15-20
Using Temporary Tables 15-21
Temporary Table 15-22
Temporary Table Characteristics 15-23
Creating a Global Temporary Table 15-24
Creating a Private Temporary Table 15-25
Lesson Agenda 15-26
External Tables 15-27
Creating a Directory for the External Table 15-28
Creating an External Table 15-30
Creating an External Table by Using ORACLE_LOADER 15-32
Querying External Tables 15-33
Creating an External Table by Using ORACLE_DATAPUMP: Example 15-34
Summary 15-35
Practice 15: Overview 15-36

16 Retrieving Data by Using Subqueries


Course Roadmap 16-2
Objectives 16-3
Lesson Agenda 16-4
Retrieving Data by Using a Subquery as a Source 16-5
Lesson Agenda 16-7
Multiple-Column Subqueries 16-8
Column Comparisons 16-9
Pairwise Comparison Subquery 16-10
Nonpairwise Comparison Subquery 16-11
Lesson Agenda 16-12
Scalar Subquery Expressions 16-13
Scalar Subqueries: Examples 16-14
Lesson Agenda 16-15
Correlated Subqueries 16-16
Using Correlated Subqueries: Example 1 16-18
Using Correlated Subqueries: Example 2 16-19
Lesson Agenda 16-20
Using the EXISTS Operator 16-21
Find All Departments That Do Not Have Any Employees 16-23
Lesson Agenda 16-24
WITH Clause 16-25
WITH Clause: Example 16-26
Recursive WITH Clause 16-27
Recursive WITH Clause: Example 16-28
Summary 16-29
Practice 16: Overview 16-30

17 Manipulating Data by Using Subqueries


Course Roadmap 17-2
Objectives 17-3
Lesson Agenda 17-4
Using Subqueries to Manipulate Data 17-5
Lesson Agenda 17-6
Inserting by Using a Subquery as a Target 17-7
Lesson Agenda 17-9
Using the WITH CHECK OPTION Keyword on DML Statements 17-10
Lesson Agenda 17-12
Correlated UPDATE 17-13
Using Correlated UPDATE 17-14
Correlated DELETE 17-16
Using Correlated DELETE 17-17
Summary 17-18
Practice 17: Overview 17-19

18 Controlling User Access


Course Roadmap 18-2
Objectives 18-3
Lesson Agenda 18-4
Controlling User Access 18-5
Privileges 18-6
System Privileges 18-7
Creating Users 18-8
User System Privileges 18-9
Granting System Privileges 18-10
Lesson Agenda 18-11
What Is a Role? 18-12
Creating and Granting Privileges to a Role 18-13
Changing Your Password 18-14
Lesson Agenda 18-15
Object Privileges 18-16
Granting Object Privileges 18-18
Passing On Your Privileges 18-19
Confirming Granted Privileges 18-20
Lesson Agenda 18-21
Revoking Object Privileges 18-22
Summary 18-24
Practice 18: Overview 18-25

19 Manipulating Data Using Advanced Queries


Course Roadmap 19-2
Objectives 19-3
Lesson Agenda 19-4
Explicit Default Feature: Overview 19-5
Using Explicit Default Values 19-6
Lesson Agenda 19-7
E-Commerce Scenario 19-8
Multitable INSERT Statements: Overview 19-9
Types of Multitable INSERT Statements 19-11
Multitable INSERT Statements 19-12
Unconditional INSERT ALL 19-14
Conditional INSERT ALL: Example 19-15
Conditional INSERT ALL 19-16
Conditional INSERT FIRST: Example 19-18
Conditional INSERT FIRST 19-19
Pivoting INSERT 19-20
Lesson Agenda 19-23
MERGE Statement 19-24
MERGE Statement Syntax 19-25
Merging Rows: Example 19-26
Lesson Agenda 19-29
FLASHBACK TABLE Statement 19-30
Using the FLASHBACK TABLE Statement 19-32
Lesson Agenda 19-33
Tracking Changes in Data 19-34
Flashback Query: Example 19-35
Flashback Version Query: Example 19-36
VERSIONS BETWEEN Clause 19-37
Summary 19-38
Practice 19: Overview 19-39

20 Managing Data in Different Time Zones


Course Roadmap 20-2
Objectives 20-3
Lesson Agenda 20-4
E-Commerce Scenario 20-5
Time Zones 20-6
TIME_ZONE Session Parameter 20-7
CURRENT_DATE, CURRENT_TIMESTAMP, and LOCALTIMESTAMP 20-8
Comparing Date and Time in a Session’s Time Zone 20-9
DBTIMEZONE and SESSIONTIMEZONE 20-11
TIMESTAMP Data Types 20-12
TIMESTAMP Fields 20-13
Difference Between DATE and TIMESTAMP 20-14
Comparing TIMESTAMP Data Types 20-15
Lesson Agenda 20-16
INTERVAL Data Types 20-17
INTERVAL Fields 20-18
INTERVAL YEAR TO MONTH: Example 20-19
INTERVAL DAY TO SECOND Data Type: Example 20-21
Lesson Agenda 20-22
EXTRACT 20-23
TZ_OFFSET 20-24
FROM_TZ 20-26
TO_TIMESTAMP 20-27
TO_YMINTERVAL 20-28
TO_DSINTERVAL 20-29
Daylight Saving Time (DST) 20-30
Summary 20-32
Practice 20: Overview 20-33

21 Conclusion
Course Goals 21-2
Oracle University: Oracle SQL Training 21-3
Oracle University: MySQL Training 21-4
Oracle SQL References 21-5
MySQL Websites 21-6
Your Evaluation 21-7
Thank You 21-8
Q&A Session 21-9

A Table Descriptions

B Using SQL Developer


Objectives B-2
What Is Oracle SQL Developer? B-3
Specifications of SQL Developer B-4
SQL Developer 17.4.1 Interface B-5
Creating a Database Connection B-7
Browsing Database Objects B-10
Displaying the Table Structure B-11
Browsing Files B-12
Creating a Schema Object B-13
Creating a New Table: Example B-14
Using the SQL Worksheet B-15
Executing SQL Statements B-18
Saving SQL Scripts B-19
Executing Saved Script Files: Method 1 B-20
Executing Saved Script Files: Method 2 B-21
Formatting the SQL Code B-22
Using Snippets B-23
Using Snippets: Example B-24
Using the Recycle Bin B-25
Debugging Procedures and Functions B-26
Database Reporting B-27
Creating a User-Defined Report B-28
External Tools B-29
Setting Preferences B-30
Data Modeler in SQL Developer B-31
Summary B-32

C Using SQL*Plus
Objectives C-2
SQL and SQL*Plus Interaction C-3
SQL Statements Versus SQL*Plus Commands C-4
SQL*Plus: Overview C-5
Logging In to SQL*Plus C-6
Displaying the Table Structure C-7
SQL*Plus Editing Commands C-9
Using LIST, n, and APPEND C-11
Using the CHANGE Command C-12
SQL*Plus File Commands C-13
Using the SAVE and START Commands C-14
SERVEROUTPUT Command C-15
Using the SQL*Plus SPOOL Command C-16
Using the AUTOTRACE Command C-17
Summary C-18

D Commonly Used SQL Commands


Objectives D-2
Basic SELECT Statement D-3
SELECT Statement D-4
WHERE Clause D-5
ORDER BY Clause D-6
GROUP BY Clause D-7
Data Definition Language D-8
CREATE TABLE Statement D-9
ALTER TABLE Statement D-10
DROP TABLE Statement D-11
GRANT Statement D-12
Privilege Types D-13
REVOKE Statement D-14
TRUNCATE TABLE Statement D-15
Data Manipulation Language D-16
INSERT Statement D-17
UPDATE Statement Syntax D-18
DELETE Statement D-19
Transaction Control Statements D-20
COMMIT Statement D-21
ROLLBACK Statement D-22
SAVEPOINT Statement D-23
Joins D-24
Types of Joins D-25
Qualifying Ambiguous Column Names D-26
Natural Join D-27
Equijoins D-28
Retrieving Records with Equijoins D-29
Additional Search Conditions Using the AND and WHERE Operators D-30
Retrieving Records with Nonequijoins D-31
Retrieving Records by Using the USING Clause D-32
Retrieving Records by Using the ON Clause D-33
Left Outer Join D-34
Right Outer Join D-35
Full Outer Join D-36
Self-Join: Example D-37
Cross Join D-38
Summary D-39

E Generating Reports by Grouping Related Data


Objectives E-2
Review of Group Functions E-3
Review of the GROUP BY Clause E-4
Review of the HAVING Clause E-5
GROUP BY with ROLLUP and CUBE Operators E-6
ROLLUP Operator E-7
ROLLUP Operator: Example E-8
CUBE Operator E-9
CUBE Operator: Example E-10
GROUPING Function E-11
GROUPING Function: Example E-12
GROUPING SETS E-13
GROUPING SETS: Example E-15
Composite Columns E-17
Composite Columns: Example E-19
Concatenated Groupings E-21
Concatenated Groupings: Example E-22
Summary E-23

F Hierarchical Retrieval
Objectives F-2
Sample Data from the EMPLOYEES Table F-3
Natural Tree Structure F-4
Hierarchical Queries F-5
Walking the Tree F-6
Walking the Tree: From the Bottom Up F-8
Walking the Tree: From the Top Down F-9
Ranking Rows with the LEVEL Pseudocolumn F-10
Formatting Hierarchical Reports Using LEVEL and LPAD F-11
Pruning Branches F-13
Summary F-14
G Writing Advanced Scripts
Objectives G-2
Using SQL to Generate SQL G-3
Creating a Basic Script G-4
Controlling the Environment G-5
The Complete Picture G-6
Dumping the Contents of a Table to a File G-7
Generating a Dynamic Predicate G-9
Summary G-11

H Oracle Database Architectural Components


Objectives H-2
Oracle Database Architecture: Overview H-3
Oracle Database Server Structures H-4
Connecting to the Database H-5
Interacting with an Oracle Database H-6
Oracle Memory Architecture H-8
Process Architecture H-10
Database Writer Process H-12
Log Writer Process H-13
Checkpoint Process H-14
System Monitor Process H-15
Process Monitor Process H-16
Oracle Database Storage Architecture H-17
Logical and Physical Database Structures H-19
Processing a SQL Statement H-21
Processing a Query H-22
Shared Pool H-23
Database Buffer Cache H-25
Program Global Area (PGA) H-26
Processing a DML Statement H-27
Redo Log Buffer H-29
Rollback Segment H-30
COMMIT Processing H-31
Summary of the Oracle Database Architecture H-33
Summary H-34

I Regular Expression Support


Objectives I-2
What Are Regular Expressions? I-3
Benefits of Using Regular Expressions I-4
Using the Regular Expressions Functions and Conditions in SQL and PL/SQL I-5
What are Metacharacters? I-6
Using Metacharacters with Regular Expressions I-7
Regular Expressions Functions and Conditions: Syntax I-9
Performing a Basic Search by Using the REGEXP_LIKE Condition I-10
Replacing Patterns by Using the REGEXP_REPLACE Function I-11
Finding Patterns by Using the REGEXP_INSTR Function I-12
Extracting Substrings by Using the REGEXP_SUBSTR Function I-13
Subexpressions I-14
Using Subexpressions with Regular Expression Support I-15
Why Access the nth Subexpression? I-16
REGEXP_SUBSTR: Example I-17
Using the REGEXP_COUNT Function I-18
Regular Expressions and Check Constraints: Examples I-19
Quiz I-20
Summary I-21
Oracle Database 19c: Administration Workshop (5 Days – 40 Hours)

Contents

1 Introduction to Oracle Database


Objectives 1-2
Oracle Database Server Architecture: Overview 1-3
Oracle Multitenant Container Database: Introduction 1-4
Oracle Multitenant Container Database: Architecture 1-5
Oracle Database Instance Configurations 1-6
Database Sharding: Introduction 1-7
Oracle Database Server: Interactive Architecture Diagram 1-8
Summary 1-9

2 Accessing an Oracle Database


Objectives 2-2
Connecting to an Oracle Database Instance 2-3
Oracle Database Tools 2-5
Database Tool Choices 2-6
SQL*Plus 2-7
Oracle SQL Developer 2-9
Oracle SQL Developer: Connections 2-10
Oracle SQL Developer: DBA Actions 2-11
Database Configuration Assistant (DBCA) 2-12
Oracle Enterprise Manager Database Express 2-13
Enterprise Manager Cloud Control 13c Features 2-15
Oracle Enterprise Manager Component Overview 2-17
Single Pane of Glass for Enterprise Management 2-18
Oracle Enterprise Manager Database Management 2-19
Summary 2-21

3 Creating an Oracle Database by Using DBCA


Objectives 3-2
Planning the Database 3-3
Choosing a Database Template 3-4
Choosing the Appropriate Character Set 3-5
How Are Character Sets Used? 3-7
Setting NLS_LANG Correctly on the Client 3-8
Using the Database Configuration Assistant 3-9
Using DBCA in Silent Mode 3-10
Summary 3-11
Practice Overview 3-12

4 Creating an Oracle Database by Using a SQL Command


Objectives 4-2
Creating a Container Database (CDB) 4-3
Creating a CDB by Using a SQL Command: Example 4-4
Using the SEED FILE_NAME_CONVERT Clause 4-5
Using the ENABLE PLUGGABLE DATABASE Clause 4-6
Summary 4-7
Practice Overview 4-8

5 Starting Up and Shutting Down a Database Instance


Objectives 5-2
Starting the Oracle Database Instance 5-3
Shutting Down an Oracle Database Instance 5-4
Comparing SHUTDOWN Modes 5-6
Opening and Closing PDBs 5-8
Configuring PDBs to Automatically Open 5-9
Summary 5-10
Practice Overview 5-11

6 Managing Database Instances


Objectives 6-2
Working with Initialization Parameters 6-3
Initialization Parameters 6-5
Modifying Initialization Parameters 6-7
Viewing Initialization Parameters 6-9
Working with the Automatic Diagnostic Repository 6-11
Automatic Diagnostic Repository 6-12
Viewing the Alert Log 6-13
Using Trace Files 6-14
Administering the DDL Log File 6-16
Querying Dynamic Performance Views 6-17
Considerations for Dynamic Performance Views 6-18
Data Dictionary: Overview 6-19
Querying the Oracle Data Dictionary 6-20
Summary 6-22
Practice Overview 6-23
7 Oracle Net Services: Overview
Objectives 7-2
Connecting to the Database Instance 7-3
Oracle Net Services: Overview 7-4
Defining Oracle Net Services Components 7-5
Tools for Configuring and Managing Oracle Net Services 7-6
Oracle Net Listener: Overview 7-7
The Default Listener 7-8
Comparing Dedicated and Shared Server Architecture 7-9
Summary 7-10

8 Configuring Naming Methods


Objectives 8-2
Establishing Oracle Network Connections 8-3
Connecting to an Oracle Database Instance 8-4
Name Resolution 8-5
Establishing a Connection 8-6
User Sessions 8-7
Naming Methods 8-8
Easy Connect 8-9
Local Naming 8-10
Directory Naming 8-11
Using Database Services to Manage Workloads 8-12
Creating Database Services 8-13
Summary 8-14
Practice Overview 8-15

9 Configuring and Administering the Listener


Objectives 9-2
Review: Oracle Net Services Overview 9-3
Oracle Net Listener: Overview 9-4
The Default Listener 9-5
Configuring Dynamic Service Registration 9-6
Configuring Static Service Registration 9-8
Summary 9-10
Practice Overview 9-11

10 Configuring a Shared Server Architecture


Objectives 10-2
Shared Server Architecture: Overview 10-3
Comparing Dedicated and Shared Server Architecture: Review 10-4
Enabling Shared Server 10-5
Controlling Shared Server Operations 10-6
SGA and PGA Usage 10-7
Shared Server Configuration Considerations 10-8
Summary 10-9
Practice Overview 10-10

11 Configuring Oracle Connection Manager for Multiplexing and Access Control


Objectives 11-2
Oracle Connection Manager: Overview 11-3
Oracle Connection Manager Processes 11-4
Oracle Connection Manager: Architecture 11-5
Using Filtering Rules 11-6
Implementing Intranet Access Control 11-7
Implementing Internet Access Control 11-8
Using Session Multiplexing 11-9
Configuring Oracle Connection Manager 11-10
Configuring the cman.ora File 11-11
Example of a cman.ora File 11-12
Configuring Clients 11-13
Configuring the Database Server 11-14
Configuring the Database Server for Multiplexing (Optional) 11-15
Using the Oracle Connection Manager Control Utility 11-16
Review of Oracle Connection Manager Features 11-17
Summary 11-18

12 Creating PDBs from Seed


Objectives 12-2
Provisioning New Pluggable Databases 12-3
Tools 12-4
Creating a New PDB from PDB$SEED 12-5
Using the FILE_NAME_CONVERT Clause 12-6
Using OMF or the PDB_FILE_NAME_CONVERT Parameter 12-7
Summary 12-8
Practice Overview 12-9

13 Using Other Techniques to Create PDBs


Objectives 13-2
Cloning Regular PDBs 13-3
Migrating Data from a Non-CDB into a CDB 13-4
Plugging a Non-CDB into CDB Using DBMS_PDB 13-5
Replicating a Non-CDB into a CDB by Using GoldenGate 13-6
Cloning a Non-CDB or Remote PDB 13-7
Using DBCA to Clone a Remote PDB 13-8
Plugging an Unplugged Regular PDB into CDB 13-9
Plugging in a PDB Using an Archive File 13-10
Cloning Remote PDBs in Hot Mode 13-11
Near-Zero Downtime PDB Relocation 13-12
Using DBCA to Relocate a Remote PDB 13-14
Proxy PDB: Query Across CDBs Proxying Root Replica 13-15
Creating a Proxy PDB 13-16
Summary 13-17

14 Managing PDBs
Objectives 14-2
Changing the PDB Mode 14-3
Modifying PDB Settings 14-4
Impact of Changing Initialization Parameters 14-5
Changing Initialization Parameters: Example 14-6
Using the ALTER SYSTEM Command in a PDB 14-7
Configuring Host Name and Port Number per PDB 14-8
Dropping PDBs 14-9
Summary 14-10
Practice Overview 14-11

15 Database Storage Overview


Objectives 15-2
Database Storage Architecture 15-3
Logical and Physical Database Structures 15-5
Segments, Extents, and Blocks 15-7
Tablespaces and Data Files 15-8
Default Tablespaces in a Multitenant Container Database 15-9
SYSTEM and SYSAUX Tablespaces 15-10
Types of Segments 15-11
How Table Data Is Stored 15-12
Database Block Content 15-13
Understanding Deferred Segment Creation 15-14
Controlling Deferred Segment Creation 15-15
Monitoring Tablespace Space Usage 15-16
Oracle Database Storage Structures: Interactive Architecture Diagram 15-17
Summary 15-18
16 Creating and Managing Tablespaces
Objectives 16-2
Creating Tablespaces 16-3
Creating a Tablespace: Clauses 16-4
Creating Permanent Tablespaces in a CDB 16-7
Defining Default Permanent Tablespaces 16-8
Temporary Tablespaces 16-9
Altering and Dropping Tablespaces 16-10
Viewing Tablespace Information 16-12
Implementing Oracle Managed Files (OMF) 16-13
Enlarging the Database 16-15
Moving or Renaming Online Data Files 16-16
Examples: Moving and Renaming Online Data Files 16-17
Summary 16-18
Practice Overview 16-19

17 Improving Space Usage


Objectives 17-2
Space Management Features 17-3
Block Space Management 17-4
Row Chaining and Migration 17-5
Free Space Management Within Segments 17-6
Allocating Extents 17-7
Using Unusable Indexes 17-8
Using Temporary Tables 17-9
Creating Global Temporary Tables 17-10
Creating Private Temporary Tables 17-11
Table Compression: Overview 17-12
Table Compression: Concepts 17-13
Compression for Direct-Path Insert Operations 17-14
Advanced Row Compression for DML Operations 17-15
Specifying Table Compression 17-16
Using the Compression Advisor 17-17
Resolving Space Usage Issues 17-18
Reclaiming Space by Shrinking Segments 17-19
Shrinking Segments 17-20
Results of a Shrink Operation 17-21
Managing Resumable Space Allocation 17-22
Using Resumable Space Allocation 17-23
Resuming Suspended Statements 17-25
What Operations Are Resumable? 17-27
Summary 17-28
Practice Overview 17-29

18 Managing Undo Data


Objectives 18-2
Undo Data: Overview 18-3
Transactions and Undo Data 18-5
Storing Undo Information 18-6
Comparing Undo Data and Redo Data 18-7
Managing Undo 18-8
Comparing SHARED Undo Mode and LOCAL Undo Mode 18-9
Configuring Undo Retention 18-10
Categories of Undo 18-11
Guaranteeing Undo Retention 18-12
Changing an Undo Tablespace to a Fixed Size 18-13
Temporary Undo: Overview 18-14
Temporary Undo Benefits 18-15
Enabling Temporary Undo 18-16
Monitoring Temporary Undo 18-17
Summary 18-18
Practice Overview 18-19

19 Creating and Managing User Accounts


Objectives 19-2
Database User Accounts 19-3
Oracle-Supplied Administrator Accounts 19-5
Creating Oracle Database Users in a Multitenant Environment 19-6
Creating Common Users in the CDB and PDBs 19-7
Creating Schema Only Accounts 19-8
Authenticating Users 19-9
Using Password Authentication 19-10
Using Password File Authentication 19-11
Using OS Authentication 19-12
OS Authentication for Privileged Users 19-14
Assigning Quotas 19-15
Summary 19-17
Practice Overview 19-18

20 Configuring Privilege and Role Authorization


Objectives 20-2
Privileges 20-3
System Privileges 20-4
System Privileges for Administrators 20-6
Object Privileges 20-7
Granting Privileges in a Multitenant Environment 20-8
Granting Privileges: Example 20-9
Using Roles to Manage Privileges 20-10
Assigning Privileges to Roles and Assigning Roles to Users 20-11
Oracle-Supplied Roles 20-12
Granting Roles in a Multitenant Environment 20-13
Granting Roles: Example 20-14
Making Roles More Secure 20-15
Revoking Roles and Privileges 20-16
Granting and Revoking System Privileges 20-17
Granting and Revoking Object Privileges 20-18
Summary 20-19
Practice Overview 20-20

21 Configuring User Resource Limits


Objectives 21-2
Profiles and Users 21-3
Creating Profiles in a Multitenant Architecture 21-4
Creating Profiles: Example 21-5
Profile Parameters: Resources 21-6
Profile Parameters: Locking and Passwords 21-8
Oracle-Supplied Password Verification Functions 21-10
Assigning Profiles in a Multitenant Architecture 21-11
Summary 21-12
Practice Overview 21-13

22 Implementing Oracle Database Auditing


Objectives 22-2
Database Security 22-3
Monitoring for Compliance 22-5
Types of Activities to be Audited 22-6
Mandatorily Audited Activities 22-7
Understanding Auditing Implementation 22-8
Administering the Roles Required for Auditing 22-9
Database Auditing: Overview 22-10
Configuring Auditing 22-11
Creating a Unified Audit Policy 22-12
Creating an Audit Policy: System-Wide Audit Options 22-13
Creating an Audit Policy: Object-Specific Actions 22-14
Creating an Audit Policy: Specifying Conditions 22-15
Enabling and Disabling Audit Policies 22-16
Auditing Actions in the CDB and PDBs 22-17
Modifying a Unified Audit Policy 22-19
Auditing Top-Level Statements Only 22-20
Viewing Audit Policy Information 22-21
Value-Based Auditing 22-22
Fine-Grained Auditing 22-24
FGA Policy 22-25
Audited DML Statement: Considerations 22-27
FGA Guidelines 22-28
Archiving and Purging the Audit Trail 22-29
Purging Audit Trail Records 22-30
Summary 22-31
Practice Overview 22-32

23 Introduction to Loading and Transporting Data


Objectives 23-2
Moving Data: General Architecture 23-3
Oracle Data Pump: Overview 23-4
Oracle Data Pump: Benefits 23-5
SQL Loader: Overview 23-7
Summary 23-9

24 Loading Data
Objectives 24-2
SQL Loader: Review 24-3
Creating the SQL*Loader Control File 24-4
SQL*Loader Loading Methods 24-6
Protecting Against Data Loss 24-7
SQL*Loader Express Mode 24-8
Using SQL*Loader to Load a Table in a PDB 24-9
Summary 24-10
Practice Overview 24-11

25 Transporting Data
Objectives 25-2
Data Pump Export and Import Clients 25-3
Data Pump Interfaces and Modes 25-4
Data Pump Import Transformations 25-6
Using Oracle Data Pump with PDBs 25-7
Exporting from a Non-CDB and Importing into a PDB 25-8
Exporting and Importing Between PDBs 25-9
Full Transportable Export/Import 25-10
Full Transportable Export/Import: Example 25-12
Transporting a Database Over the Network: Example 25-13
Using RMAN to Transport Data Across Platforms 25-14
RMAN CONVERT Command 25-15
Transporting Data with Minimum Down Time 25-16
Transporting a Tablespace by Using Image Copies 25-17
Determining the Endian Format of a Platform 25-18
Transporting Data with Backup Sets 25-19
Transporting a Tablespace 25-20
Transporting Inconsistent Tablespaces 25-22
Database Transport: Data Files 25-23
Transporting a Database 25-24
Transporting a Database: Conversion 25-25
Transporting a Database: Example 1 25-26
Transporting a Database: Example 2 25-27
Transporting a Database: Considerations 25-28
Transporting a Database with Backup Sets 25-29
Summary 25-31
Practice Overview 25-32

26 Using External Tables to Load and Transport Data


Objectives 26-2
External Tables 26-3
External Tables: Benefits 26-4
ORACLE_LOADER Access Driver 26-5
ORACLE_DATAPUMP Access Driver 26-6
External Tables 26-7
Viewing Information About External Tables 26-8
Summary 26-9
Practice Overview 26-10

27 Automated Maintenance Tasks: Overview


Objectives 27-2
Proactive Database Maintenance Infrastructure 27-3
Automated Maintenance Tasks: Components 27-4
Predefined Automated Maintenance Tasks 27-5
Maintenance Windows 27-6
Predefined Maintenance Windows 27-7
Viewing Maintenance Window Details 27-8
Automated Maintenance Tasks 27-9
Summary 27-10

28 Automated Maintenance Tasks: Managing Tasks and Windows


Objectives 28-2
Configuring Automated Maintenance Tasks 28-3
Enabling and Disabling Maintenance Tasks 28-4
Creating and Managing Maintenance Windows 28-5
Resource Allocations for Automated Maintenance Tasks 28-6
Changing Resource Allocations for Maintenance Tasks 28-7
Summary 28-8
Practice Overview 28-9

29 Database Monitoring and Tuning Performance Overview


Objectives 29-2
Performance Management Activities 29-3
Performance Planning Considerations 29-4
Database Maintenance 29-6
Automatic Workload Repository (AWR) 29-7
Automatic Database Diagnostic Monitor (ADDM) 29-8
Configuring Automatic ADDM Analysis at the PDB Level 29-9
Advisory Framework 29-10
Performance Tuning Methodology 29-12
Summary 29-13

30 Monitoring Database Performance


Objectives 30-2
Server-Generated Alerts 30-3
Setting Metric Thresholds 30-4
Reacting to Alerts 30-5
Alert Types and Clearing Alerts 30-6
Database Server Statistics and Metrics 30-7
Performance Monitoring 30-8
Viewing Statistics Information 30-9
Monitoring Wait Events 30-11
Monitoring Sessions 30-12
Monitoring Services 30-13
Summary 30-14
31 Analyzing SQL and Optimizing Access Paths
Objectives 31-2
SQL Tuning Process 31-3
Oracle Optimizer 31-4
Optimizer Statistics 31-5
Optimizer Statistics Collection 31-6
Setting Optimizer Statistics Preferences 31-8
Optimizer Statistics Advisor 31-10
Optimizer Statistics Advisor Report 31-11
Executing Optimizer Statistics Advisor Tasks 31-12
SQL Plan Directives 31-13
Adaptive Execution Plans 31-14
SQL Tuning Advisor: Overview 31-16
SQL Access Advisor: Overview 31-18
SQL Performance Analyzer: Overview 31-19
Managing Automated Tuning Tasks 31-21
Summary 31-22
Oracle Database 19c: Backup and Recovery (5 Days – 40 Hours)

Contents

1 Backup and Recovery: Overview


Objectives 1-2
DBA Responsibilities 1-3
Separation of DBA Duties 1-4
Assessing Your Recovery Requirements 1-5
Categories of Failure 1-7
Statement Failure 1-8
User Process Failure 1-9
Network Failure 1-10
User Error 1-11
Instance Failure 1-12
Media Failure 1-13
Data Failures 1-14
Instance Recovery 1-15
The Checkpoint (CKPT) Process 1-16
Redo Log Files and the Log Writer (LGWR) Process 1-17
Database Log Mode 1-18
Automatic Instance Recovery or Crash Recovery 1-19
Phases of Instance Recovery 1-20
Tuning Instance Recovery 1-21
Using the MTTR Advisor 1-22
Restoring and Recovering 1-23
Comparing Complete and Incomplete Recovery 1-24
The Complete Recovery Process 1-25
The Point-in-Time Recovery Process 1-26
Oracle Data Protection Solutions 1-28
Flashback Technology 1-29
Summary 1-30

2 Backup and Recovery Configuration


Objectives 2-2
Configuring for Recoverability 2-3
Configuring the Fast Recovery Area 2-4
Monitoring the Fast Recovery Area 2-5
Multiplexing Control Files 2-6
Redo Log Files 2-8
Multiplexing the Redo Log 2-9
Creating Archived Redo Log Files 2-10
Archiver (ARCn) Process 2-11
Archived Redo Log Files: Naming and Destinations 2-12
Configuring ARCHIVELOG Mode 2-13
Summary 2-14
Practice Overview 2-15

3 Using Recovery Manager (RMAN)


Objectives 3-2
Integrated Oracle Recovery Manager (RMAN) 3-3
Connecting to RMAN and a Target Database 3-4
Using SQL in RMAN 3-5
Types of RMAN Commands 3-6
Job Commands: Example 3-7
Configuring Persistent Settings for RMAN 3-8
Viewing Persistent Settings 3-9
Managing Persistent Settings 3-10
Specifying a Retention Policy 3-11
Recovery Window Retention Policy: Example 3-13
Summary 3-14
Practice Overview 3-15

4 Backup Strategies
Objectives 4-2
Understanding Types of Backups 4-3
Backup Terminology 4-4
Understanding Types of Backups 4-5
RMAN Backup Types 4-6
Backup Solutions: Overview 4-8
Balancing Backup and Restore Requirements 4-9
Comparing Backup Strategies 4-11
Option 1: Full and Incremental Backups 4-12
Option 2: Incrementally Updated Disk Backups 4-13
Option 3: Offloading Backups to Physical Standby Database in Data
Guard Environment 4-14
Backing Up Read-Only Tablespaces: Considerations 4-15
Data Warehouse Backup and Recovery: Best Practices 4-16
Summary 4-17
5 Creating Database Backups
Objectives 5-2
Using RMAN Commands to Create Backups 5-3
Syntax and Clauses in RMAN 5-4
Creating Backup Sets 5-5
Creating Image Copies 5-6
Creating a Whole Database Backup 5-7
CDB Backup: Whole CDB Backup 5-8
CDB Backup: Partial CDB Backup 5-9
PDB Backup: Partial PDB Backup 5-10
Review: RMAN Backup Types 5-11
Incrementally Updated Backups 5-13
Incrementally Updated Backups: Example 5-14
Fast Incremental Backup 5-15
Maintaining the Block Change Tracking File 5-16
Monitoring Block Change Tracking 5-17
Automatic Disk-to-Disk Backup and Recovery 5-18
Oracle-Suggested Backup 5-19
Backing Up the Control File to a Trace File 5-20
Cataloging Additional Backup Files 5-22
Reporting on Backups 5-23
Using Dynamic Views 5-24
Summary 5-25
Practice Overview 5-26

6 Using Optional Backup Features


Objectives 6-2
Saving Backup Space with Unused Block Compression 6-3
Compressing Backups 6-4
Using RMAN Backup Compression 6-5
Using a Media Manager 6-6
Configuring Backup and Restore for Very Large Files 6-8
Backing Up and Restoring Very Large Files 6-9
Creating RMAN Multisection Backups 6-10
Creating Proxy Copies 6-11
Creating Duplexed Backup Sets by Using BACKUP COPIES 6-12
Creating Backups of Backup Sets 6-13
Archival Backups: Concepts 6-14
Creating Archival Backups with RMAN 6-16
Managing Archival Database Backups 6-17
Backing Up Recovery Files 6-18
Summary 6-19
Practice Overview 6-20

7 Tuning RMAN Backup Performance


Objectives 7-2
Is There a Problem? 7-3
Diagnosing Performance Bottlenecks 7-4
Diagnosing Performance Bottlenecks: Read Phase 7-5
Is There a “Write” Problem? 7-6
Diagnosing Performance Bottlenecks: Write or Copy Phase 7-7
Using Dynamic Views to Diagnose RMAN Performance 7-8
Monitoring RMAN Job Progress 7-9
Identifying Backup and Restore Bottlenecks 7-11
Asynchronous I/O Bottlenecks 7-12
Synchronous I/O Bottlenecks 7-13
Tuning RMAN Backup Performance 7-14
Parallelization of Backup Sets 7-15
RMAN Multiplexing 7-17
Summary 7-19
Practice Overview 7-20

8 Recovery Catalog Overview


Objectives 8-2
RMAN Repository Data Storage: Comparison of Options 8-3
Storing Information in the Recovery Catalog 8-4
Reasons to Use a Recovery Catalog 8-5
Summary 8-6

9 Creating a Recovery Catalog


Objectives 9-2
Creating the Recovery Catalog: Three Steps 9-3
1. Configuring the Recovery Catalog Database 9-4
2. Creating the Recovery Catalog Owner 9-5
3. Creating the Recovery Catalog 9-6
Summary 9-7
Practice Overview 9-8

10 Managing Target Database Records


Objectives 10-2
Managing Target Database Records in the Recovery Catalog 10-3
Registering a Database in the Recovery Catalog 10-4
Unregistering a Target Database from the Recovery Catalog 10-5
Recovery Catalog Resynchronization: Concepts 10-6
Manually Resynchronizing the Recovery Catalog 10-8
Summary 10-9
Practice Overview 10-10

11 Using Stored Scripts


Objectives 11-2
Using RMAN Stored Scripts 11-3
Executing RMAN Stored Scripts 11-4
Maintaining RMAN Stored Scripts 11-5
Summary 11-6
Practice Overview 11-7

12 Creating and Using Virtual Private Catalogs


Objectives 12-2
Creating and Using Virtual Private Catalogs 12-3
Creating a Virtual Private Catalog 12-4
Managing Virtual Private Catalogs 12-6
Upgrading Virtual Private Catalogs 12-7
Summary 12-8
Practice Overview 12-9

13 Restore and Recovery Concepts


Objectives 13-2
File Loss 13-3
Data Repair Techniques 13-4
Restoring and Recovering 13-5
Using RMAN RESTORE and RECOVER Commands 13-6
Instance Failure 13-7
Instance Recovery 13-8
Phases of Instance Recovery 13-9
Media Failure 13-10
Comparing Complete and Incomplete Recovery 13-11
Complete Recovery Process 13-12
Point-in-Time Recovery Process 13-13
Recovery with the RESETLOGS Option 13-15
Restore and Recovery Performance: Best Practices 13-16
Summary 13-17
14 Diagnosing Failures
Objectives 14-2
Reducing Problem Diagnosis Time 14-3
Automatic Diagnostic Workflow 14-4
Automatic Diagnostic Repository 14-5
ADR Command-Line Tool (ADRCI) 14-6
V$DIAG_INFO View 14-7
Data Recovery Advisor 14-8
Data Failure: Examples 14-11
Data Recovery Advisor RMAN Command-Line Interface 14-12
Listing Data Failures 14-13
Advising on Repair 14-15
Executing Repairs 14-16
Classifying (and Closing) Failures 14-17
Data Recovery Advisor Views 14-18
Summary 14-19
Practice Overview 14-20

15 Performing Complete Recovery


Objectives 15-2
Ensuring Backups Are Available 15-3
Restoring in NOARCHIVELOG Mode 15-4
Recovery with Incremental Backups in NOARCHIVELOG Mode 15-5
Performing Complete Recovery 15-6
Review: Recovering Image Copies 15-8
Recovering Image Copies: Example 15-9
Performing a Fast Switch to Image Copies 15-10
Using SET NEWNAME for Switching Files 15-11
Using Restore Points 15-12
PDB Tempfile Recovery 15-13
PDB SYSTEM or UNDO Tablespace Recovery 15-14
PDB Non-SYSTEM Tablespace Recovery 15-15
Summary 15-16
Practice Overview 15-17

16 Performing Point-in-Time Recovery


Objectives 16-2
Point-in-Time Recovery 16-3
PITR Terminology 16-4
Performing Point-in-Time Recovery 16-5
When to Use TSPITR 16-7
Tablespace Point-in-Time Recovery: Architecture 16-8
Preparing for TSPITR 16-10
Determining the Correct Target Time 16-11
Determining the Tablespaces for the Recovery Set 16-12
Identifying Objects That Will Be Lost 16-13
Performing RMAN TSPITR 16-14
Performing Fully Automated TSPITR 16-15
Improving TSPITR Performance 16-16
Performing RMAN TSPITR with an RMAN-Managed Auxiliary Instance 16-17
Performing RMAN TSPITR by Using Your Own Auxiliary Instance 16-18
Troubleshooting RMAN TSPITR 16-19
PITR of PDBs 16-20
Recovering Tables from Backups 16-21
Table Recovery: Graphical Overview 16-22
Prerequisites and Limitations 16-23
Specifying the Recovery Point in Time 16-24
Process Steps of Table Recovery 16-25
Summary 16-27
Practice Overview 16-28

17 Performing Block Media Recovery


Objectives 17-2
What Is Block Corruption? 17-3
Block Corruption Symptoms: ORA-01578 17-4
How to Handle Corruption 17-5
Setting Parameters to Detect Corruption 17-6
Block Media Recovery 17-7
Prerequisites for Block Media Recovery 17-8
Recovering Individual Blocks 17-9
Best Practice: Proactive Checks 17-10
Checking for Block Corruption 17-11
Summary 17-12
Practice Overview 17-13

18 Performing Additional Recovery Operations


Objectives 18-2
Recovery from Loss of Server Parameter File 18-3
Restoring the Server Parameter File from the Control File Autobackup 18-4
Loss of a Control File 18-5
Recovering from the Loss of All Control File Copies: Overview 18-6
Restoring the Control File from Autobackup 18-7
Restoring the SPFILE and the Control File 18-8
Recovering NOLOGGING Database Objects 18-9
Loss of a Redo Log File 18-10
Log Group Status: Review 18-11
Recovering from the Loss of a Redo Log Group 18-12
Clearing a Log File 18-13
Re-creating a Password Authentication File 18-14
Summary 18-16
Practice Overview 18-17

19 Oracle Flashback Technology: Overview


Objectives 19-2
Flashback Technologies Error Detection and Correction 19-3
Review: Transactions and Undo 19-4
Flashback Technology 19-5
Summary 19-7

20 Using Logical Flashback Features


Objectives 20-2
Using Flashback Technology to Query Data 20-3
Flashback Query 20-4
Flashback Version Query 20-5
Flashback Table: Overview 20-6
Flashback Table 20-7
Flashback Table: Considerations 20-8
Flashback Transaction Query 20-9
Flashback Transaction Query: Considerations 20-10
Flashback Transaction Backout 20-11
Flashing Back a Transaction 20-12
Best Practices: Undo-Based Flashback Query, Flashback Table 20-13
Flashback Drop and the Recycle Bin 20-14
Recycle Bin 20-15
Bypassing the Recycle Bin 20-16
Using Flashback Data Archives 20-17
Creating a Temporal History and Enabling Archiving 20-18
How the Flashback Data Archive Works 20-19
Collecting User Context in Temporal History 20-20
Transparent Schema Evolution 20-21
Full Schema Evolution 20-22
Temporal Validity and History 20-23
Using the PERIOD FOR Clause 20-24
Filtering on Valid-Time Columns: Example 1 20-25
Filtering on Valid-Time Columns: Example 2 20-26
Using DBMS_FLASHBACK_ARCHIVE 20-27
Summary 20-28
Practice Overview 20-29

21 Using Flashback Database


Objectives 21-2
Preparing Your Database for Flashback 21-3
Guaranteeing Undo Retention 21-4
Flashback Database: Continuous Data Protection 21-5
Flashback Database 21-6
Flashback Database Architecture 21-7
Configuring Flashback Database 21-8
Flashback Database: Examples 21-9
CDB and PDB Flashback 21-10
Flashback Database Considerations 21-11
Monitoring Flashback Database Information 21-12
Guaranteed Restore Points 21-14
Flashback Database and Guaranteed Restore Points 21-15
PDB Flashback and Clean Restore Point 21-16
Best Practices: Flashback Database 21-17
Summary 21-19
Practice Overview 21-20

22 Using PDB Snapshots


Objectives 22-2
PDB Snapshot Carousel 22-3
Creating PDB Snapshots 22-4
Creating PDBs by Using PDB Snapshots 22-5
Dropping PDB Snapshots 22-6
Flashing Back PDBs by Using PDB Snapshots 22-7
Summary 22-8

23 Database Duplication Overview


Objectives 23-2
Using a Duplicate Database 23-3
Choosing Database Duplication Techniques 23-4
Duplicating an Active Database with “Push” 23-5
Comparing the “Push” and “Pull” Methods of Duplication 23-6
Duplicating a Database with a Target Connection 23-7
Duplicating a Database with a Recovery Catalog 23-8
Duplicating a Database Without a Recovery Catalog or Target Connection 23-9
Summary 23-10

24 Creating a Backup-Based Duplicate Database


Objectives 24-2
Creating a Backup-Based Duplicate Database 24-3
Creating an Initialization Parameter File for the Auxiliary Instance 24-4
Specifying New Names for Your Destination 24-5
Using the SET NEWNAME Clauses 24-6
Substitution Variables for SET NEWNAME 24-7
Specifying Parameters for File Naming 24-8
Starting the Instance in NOMOUNT Mode 24-9
Ensuring That Backups and Archived Redo Log Files Are Available 24-10
Allocating Auxiliary Channels 24-11
Understanding the RMAN Duplication Operation 24-12
Specifying Options for the DUPLICATE Command 24-14
Using Additional DUPLICATE Command Options 24-15
Duplicating Selected PDBs in a CDB 24-16
Cloning an Active PDB into an Existing CDB 24-17
Example: Duplicating PDB1 from CDB1 to CDB2 as PDB1 24-18
Example: Duplicating PDB1 from CDB1 to CDB2 as PDB2 24-19
Summary 24-20
Practice Overview 24-21
Oracle Database 19c: Multitenant Architecture (4 Days – 32 Hours)

Course Practice Environment: Security Credentials ................................................................... 7


Course Practice Environment: Security Credentials ...................................................................... 8
Practices for Lesson 1: CDB Basics .............................................................................................. 9
Practices for Lesson 1: Overview ................................................................................................... 10
Practice 1-1: Discovering Practices Environment .......................................................................... 12
Practice 1-2: Setting and Validating OEMCC Named Credentials ................................................. 13
Practice 1-3: Exploring CDB and PDB using Enterprise Manager Cloud Control.......................... 18
Practice 1-4: Using Enterprise Manager Express .......................................................................... 31
Practices for Lesson 2: CDB and Regular PDBs .......................................................................... 39
Practices for Lesson 2: Overview ................................................................................................... 40
Practice 2-1: Exploring CDB Architecture and Structures .............................................................. 41
Practice 2-2: Creating a New CDB ................................................................................................. 52
Practice 2-3: Creating a New PDB ................................................................................................. 60
Practices for Lesson 3: Application PDBs and Application Installation .................................... 69
Practices for Lesson 3: Overview ................................................................................................... 70
Practice 3-1: Installing an Application in an Application Container ................................................ 71
Practice 3-2: Upgrading an Application in an Application Container .............................................. 80
Practice 3-3: Querying Data Across Application PDBs in CDB...................................................... 86
Practices for Lesson 4: PDB Creation ........................................................................................... 103
Practices for Lesson 4: Overview ................................................................................................... 104
Practice 4-1: Cloning Remote PDBs in Hot Mode .......................................................................... 105
Practice 4-2: Cloning an Application Container .............................................................................. 112
Practice 4-3: Unplugging and Plugging Application Containers ..................................................... 119
Practice 4-4: Converting a Regular PDB to an Application PDB ................................................... 126
Practice 4-5: Relocating PDBs ....................................................................................................... 133
Practice 4-6: Querying Data Across CDBs by Using Proxy PDBs ................................................. 141
Practice 4-7: Dropping Unnecessary PDBs ................................................................................... 152
Practices for Lesson 5: CDB and PDB Management ................................................................... 157
Practices for Lesson 5: Overview ................................................................................................... 158
Practice 5-1: Starting Up and Shutting Down a CDB ..................................................................... 159
Practice 5-2: Opening and Closing PDBs ...................................................................................... 164
Practice 5-3: Renaming a PDB ...................................................................................................... 170
Practice 5-4: Setting Parameter Values for PDBs .......................................................................... 173
Practice 5-5: Renaming PDB Services........................................................................................... 177
Practices for Lesson 6: Storage ..................................................................................................... 183
Practices for Lesson 6: Overview ................................................................................................... 184
Practice 6-1: Managing Permanent and Temporary Tablespaces ................................................. 185
Practice 6-2: Managing UNDO Tablespaces ................................................................................. 192
Practices for Lesson 7: Security .................................................................................................... 195
Practices for Lesson 7: Overview ................................................................................................... 196
Practice 7-1: Managing Common and Local Users, Privileges, and Roles.................................... 197
Practice 7-2: Managing Common and Local Objects in Application Containers ............................ 243
Practice 7-3: Enabling Common Users to View Information About PDB Objects .......................... 254
Practice 7-4: Managing PDB Lockdown Profiles ............................................................................ 258
Practice 7-5: Auditing Operations in PDBs .................................................................................... 261
Practice 7-7: Unplugging and Plugging Encrypted PDBs .............................................................. 281
Practices for Lesson 8: Backup and Duplicate ............................................................................. 287
Practices for Lesson 8: Overview ................................................................................................... 288
Practice 8-1: RMAN Whole CDB Backup ....................................................................................... 289
Practice 8-2: RMAN PDB Backup .................................................................................................. 296
Practice 8-3: Duplicating a PDB into an Existing CDB ................................................................... 301
Practice 8-4: Duplicating an On-Premises CDB for Cloud ............................................................. 306
Practices for Lesson 9: Recovery and Flashback ........................................................................ 325
Practices for Lesson 9: Overview ................................................................................................... 326
Practice 9-1: RMAN Recovery from SYSTEM PDB Data File Loss ............................................... 327
Practice 9-2: RMAN Recovery from Nonessential PDB Data File Loss ......................................... 343
Practice 9-3: PDB PITR .................................................................................................................. 346
Practice 9-4: Recovering a Plugged PDB by Using Preplug-in Backups ....................................... 351
Practice 9-5: Flashing Back an Application Upgrade by Using Restore Points ............................. 372
Practices for Lesson 10: Performance .......................................................................................... 379
Practices for Lesson 10: Overview ................................................................................................. 380
Practice 10-1: Monitoring Performance at the CDB and PDB Levels ............................................ 381
Practice 10-2: Getting Performance ADDM Recommendations at CDB and PDB Levels ............ 388
Practice 10-3: Monitoring SQL Executions at PDB Level .............................................................. 407
Practices for Lesson 11: Resources Allocation ........................................................................... 419
Practices for Lesson 11: Overview ................................................................................................. 420
Practice 11-1: Managing PDB Performance Profiles ..................................................................... 421
Practice 11-2: Managing Resource Allocation Between PDBs ...................................................... 430
Practice 11-3: Avoiding Excessive Session PGA Memory Usage in PDBs ................................... 436
Practices for Lesson 12: Data Movement ...................................................................................... 441
Practices for Lesson 12: Overview ................................................................................................. 442
Practice 12-1: Performing a Full Transportable Export/Import from a 12c Non-CDB into an 18c PDB
........................................................................................................................................................ 443
Practice 12-2: Performing a Full Transportable Export/Import from a 18c PDB into an 19c PDB . 447
Practices for Lesson 13: Upgrade Methods .................................................................................. 451
Practices for Lesson 13: Overview ................................................................................................. 452
Practice 13-1: Upgrading an 18c Regular PDB to a 19c Application PDB ..................................... 453
Practice 13-2: Plugging Remote PDBs Through XTTS.................................................................. 487
Practice 13-3: Upgrading an 18c CDB to a 19c CDB ..................................................................... 494

You might also like