Professional Documents
Culture Documents
Workshop
Electronic Presentation
D78846GC20
Edition 2.0 | December 2016
Learn more from Oracle University at education.oracle.com
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Authors
Disclaimer
Donna K. Keesling
James L. Spiller This document contains proprietary information and is protected by copyright and other
intellectual property laws. You may copy and print this document solely for your own use in an
Oracle training course. The document may not be modified or altered in any way. Except where
Technical Contributors your use constitutes "fair use" under copyright law, you may not use, share, download, upload,
copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this
and Reviewers document in whole or in part without the express authorization of Oracle.
Daryl Balaski
The information contained in this document is subject to change without notice. If you find any
Rainer Bien problems in the document, please report them in writing to: Oracle University, 500 Oracle
Parkway, Redwood Shores, California 94065 USA. This document is not warranted to be error-
Maria Billings
free.
Andy Fortunak
Restricted Rights Notice
Joel Goodman
Daniela Hansell If this documentation is delivered to the United States Government or anyone using the
documentation on behalf of the United States Government, the following notice is applicable:
Pat Huey
Dominique Jeunot U.S. GOVERNMENT RIGHTS
The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or disclose
Gwen Lazenby these training materials are restricted by the terms of the applicable Oracle license agreement
and/or the applicable U.S. Government contract.
Ira Singer
Lori Tritz Trademark Notice
Branislav Valny Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be
Harald Van Breederode trademarks of their respective owners.
Editors
Vijayalakshmi Narasimhan
Malavika Jinka
Publishers
Veena Narasimhan
Jayanthy Keshavamurthy
Introduction
1-2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Course Objectives
1-3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Suggested Schedule
1-4 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Oracle Database Innovation
Private DB Cloud
… continuing with Defense in Depth
Oracle Database 12c Information Lifecycle Mgt
Extreme Availability
Flex Clusters
Performance and Ease of Use
Oracle Grid Infrastructure
… with Oracle Database 11g Real Application Testing
Automatic SQL Tuning
Fault Management
Audit Vault
Database Vault
… with Oracle Secure Enterprise Search
Database 10g Grid Computing
Automatic Storage Mgmt
Self Managing Database
XML Database, Oracle Data Guard, RAC, Flashback Query, Virtual Private Database
Built-in Java VM , Partitioning Support, Built-in Messaging, Object Relational Support, Multimedia Support
1-5 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Enterprise Cloud Computing
Enterprise Manager
RAC Grids of Managing Cloud Control and
clusters low-cost change database
for hardware and across the consolidation across
availability storage enterprise the enterprise
1-6 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Course Examples: HR Sample Schema
REGIONS
REGION_ID (PK)
REGION_NAME
JOBS
COUNTRIES JOB_ID (PK)
COUNTRY_ID (PK) JOB_TITLE
COUNTRY_NAME MIN_SALARY JOB_HISTORY
REGION_ID (FK) MAX_SALARY EMPLOYEE_ID (PK)
START_DATE (PK)
END_DATE
JOB_ID (FK)
LOCATIONS EMPLOYEES DEPARTMENT_ID (FK)
LOCATION_ID (PK) EMPLOYEE_ID (PK)
STREET_ADDRESS FIRST_NAME
POSTAL_CODE LAST_NAME
CITY EMAIL
STATE_PROVINCE PHONE_NUMBER
COUNTRY_ID (FK) HIRE_DATE
JOB_ID (FK)
SALARY
COMMISION_PCT
DEPARTMENTS MANAGER_ID (FK)
DEPARTMENT_ID (PK) DEPARTMENT_ID (FK)
DEPARTMENT_NAME
MANAGER_ID
LOCATION_ID (FK)
1-7 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Summary
1-8 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Exploring Oracle Database Architecture
2-2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Oracle Database Server Architecture: Overview
Instance
PGA
Server
process Memory Structures
(System Global Area)
Server
Process Structures
User
process
2-3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Oracle Database Instance Configurations
I1
I1 I2 I3
I2
D1
D2
Local Storage D
Shared Storage
2-4 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Connecting to the Database Instance
User Server
SQL> Select … process process
User
Session
Connection
Session
2-5 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Oracle Database Memory Structures
Database
Redo log
Shared pool buffer
buffer
cache
Streams
Large pool Java pool Fixed SGA
pool
2-6 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Shared Pool
Library
Cache Reserved Pool
Database
Redo log
Shared pool buffer
buffer
cache
Streams
Large pool Java pool Fixed SGA
pool
2-8 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Database Buffer Cache
Keep pool
Recycle Database
pool Redo log
Shared pool buffer
buffer
cache
nK buffer
cache
Streams
Large pool Java pool Fixed SGA
pool
Database
Redo log
Shared pool buffer
buffer
cache
Redo log
Database
buffer
Shared pool buffer
cache Free Parallel
I/O buffer
RECYCLE memory
Query
buffer pool
Response Request Advanced
Streams queue
Large pool Java pool Fixed SGA queue Queuing
pool
Large pool
System Global Area (SGA)
Streams
Large pool Java pool Fixed SGA
pool
Streams nK buffer
Large pool Java pool
pool cache
Database
Redo log
Shared pool buffer buffer
cache
Streams
Large pool Java pool Fixed SGA
pool
– Segment attributes
No
Loaded in buffer cache LRU
if table size < small %
of buffer cache size
Table SH.SALES
What is read into the database buffer cache from data files?
a. Rows
b. Changes
c. Blocks
d. SQL
• User process
– Is the application or tool that connects to the Oracle
database
• Database processes
– Server process: Connects to the Oracle instance and is
started when a user establishes a session
– Background processes: Are started when an Oracle instance
is started
• Daemon / Application processes
– Networking listeners
– Grid Infrastructure daemons
DBWn
LGWR
Redo log
buffer
LGnn
Checkpoint
process
Data files
Instance
SMON
System Monitor
process
Temporary
segment
Server
process
PMON
User
Database buffer
Failed user process Process Monitor
cache
process
RECO
Instance
Memory Structures
(System Global Area)
Process Structures
LREG listener
ARCn
Logical Physical
Database
Segment
Storage System
• SAN • NFS
Extent
• NAS • ASM
• Exadata
Oracle data
• File System
block
Extent Extent
64 KB 64 KB
Segment
128 KB
Multitenant
container
database Data files Control files Redo Log files
UNDO
SYSTEM
Operating system
ASM
Oracle
ASM
Database ASM file
disk group
Data file
ASM
extent
Database
Redo log
Shared pool buffer
PGA buffer
cache
Server
process
Java pool Streams
Large pool Fixed SGA
pool
Listener
DBWn CKPT LGWR SMON PMON RECO ARCn Others
User
process
User
3-2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Oracle Database Management Tools: Introduction
3-3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Using SQL*Plus
SQL*Plus is:
• A command-line tool
• Used interactively or in batch mode
$ sqlplus hr
Enter password:
Last Successful login time: Mon Oct 06 2014 13:24:35 +00:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
3-4 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Calling SQL*Plus from a Shell Script
$ ./batch_sqlplus.sh
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics, Real Application Testing and
Unified Auditing options # Name of this file: batch_sqlplus.sh
# Count employees and give raise.
SQL>
COUNT(*)
sqlplus hr/hr <<EOF
---------- select count(*) from employees;
107 update employees set salary = salary*1.10;
SQL> commit;
107 rows updated. quit
SQL> EOF
Commit complete.
SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0
- 64bit Production
With the Partitioning, OLAP, Advanced Analytics, Real Application Testing
and Unified Auditing options
$
3-5 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Calling a SQL Script from SQL*Plus
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics, Real Application Testing
and Unified Auditing options
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit
Production
With the Partitioning, OLAP, Advanced Analytics, Real Application Testing
and Unified Auditing options
3-6 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Oracle SQL Developer: Connections
3-7 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Oracle SQL Developer: DBA Actions
Using DBA features through DBA navigator
3-8 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Oracle Enterprise Manager
Database Express Architecture
Listener
Console
EM Express Servlet
• Authentication
• Session Management
• Compression File
• Caching
Manager
Get shell files
3-9 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Configuring Enterprise Manager
Database Express
• Configure an HTTP listener port for each database
instance.
– Verify DISPATCHERS parameter.
dispatchers=(PROTOCOL=TCP)(SERVICE=sampleXDB)
Managed
Hosts
Oracle Management
Service
Cloud Control
Console
Oracle Management
Repository
WebLogic
EM
OMS
Repository Agents
SQL*Plus or Enterprise
Server Control Enterprise
Manager
Manager Control
Listener Control Control
WebLogic
EM
OHS
Repository OMS
Agents
WebLogic
EM
OHS
Agents OMS Repository
4-2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Initialization Parameter Files
spfileorcl.ora
or
initorcl.ora
4-3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Types of Initialization Parameters
Basic Advanced
CONTROL_FILES COMMIT_LOGGING
DB_BLOCK_SIZE COMMIT_WAIT
PROCESSES DB_CACHE_SIZE
UNDO_TABLESPACE SHARED_POOL_SIZE
… …
4-5 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Initialization Parameters: Examples
Parameter Specifies
4-6 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Initialization Parameters: Examples
PGA PGA
Database
Redo log
Shared pool buffer
buffer
cache
Streams
Large pool Java pool Fixed SGA
pool
4-7 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Initialization Parameters: Examples
Parameter Specifies
4-9 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Using SQL*Plus to View Parameters
SQL> SELECT name, value FROM v$parameter;
NAME VALUE
------------ ----------
lock_name_space
processes 300
sessions 472
timed_statistics TRUE
timed_os_statistics 0
…
• Static parameters:
– Can be changed only in the parameter file
– Require restarting the instance before taking effect
• Dynamic parameters:
– Can be changed while database is online
– Can be altered at:
— Session level
— System level
– Are valid for duration of session or based on SCOPE setting
– Are changed by using the ALTER SESSION and ALTER
SYSTEM commands
Session altered.
SYSDATE
-----------
oct 17 2012
System altered.
OPEN
STARTUP
MOUNT
NOMOUNT
Instance
started
SHUTDOWN
OPEN
STARTUP
MOUNT
Control file
opened for this
NOMOUNT instance
Instance
started
SHUTDOWN
OPEN
STARTUP All files opened as
described by the control
MOUNT file for this instance
Control file
opened for this
NOMOUNT instance
Instance
started
SHUTDOWN
Shutdown Modes A I T N
Shutdown modes:
• A = ABORT
• I = IMMEDIATE
• T = TRANSACTIONAL
• N = NORMAL
Consistent database
• Using SQL*Plus:
SQL> shutdown 1
Tables
Indexes
SYSTEM Tablespace
Views
Users
Schemas
Procedures
Metadata
…and so on
ALL_ Everyone Everything that DBA_ views Includes user’s own objects
the user has and other objects that the
privileges to user has been granted
see privileges to see
USER_ Everyone Everything that ALL_ views Is usually the same as ALL_
the user owns except for the missing
OWNER column. (Some
views have abbreviated
names as PUBLIC
synonyms.)
4 DESCRIBE dba_indexes
Which data dictionary view can be used to find the names of all
tables in the database?
a. USER_TABLES
b. ALL_TABLES
c. DBA_TABLES
d. ANY_TABLES
5-2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Oracle Net Services: Overview
Application RDBMS
5-3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Oracle Net Listener: Overview
Oracle Net
configuration files
<ORACLE_HOME>/network/admin/listener.ora
./sqlnet.ora
5-4 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Establishing Oracle Network Connections
Names resolution
5-5 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Connecting to an Oracle Database
finance.us.flowers.com
Database server
5-6 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Name Resolution
CONNECT jsmith/jspass@finflowers
Name resolution
finflowers =(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=flowers-server)(PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=finance.us.flowers.com)))
LISTENER
port 1521 finance
flowers-server
5-7 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Establishing a Connection
Incoming connection
request Listener
5-8 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
User Sessions
Server
process
User process
Listener
5-9 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Naming Methods
Client/application server
Oracle Net
• Is enabled by default
• Requires no client-side configuration
• Supports only TCP/IP (no SSL)
• Offers no support for advanced connection options such
as:
– Connect-time failover
– Source routing
– Load balancing
SQL> CONNECT hr/hr@db.us.oracle.com:1521/dba11g
Oracle Net
configuration files
LDAP directory
SQL> CONNECT hr/hr@orcl
Oracle Net
configuration files
Non-Oracle
naming
service
Oracle Net
$ lsnrctl
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 08-OCT-2014 10:07:23
LSNRCTL> help
The following operations are available
An asterisk (*) denotes a modifier or extended command:
• Prompt syntax:
LSNRCTL> <command name>
LSNRCTL> start
LSNRCTL> status
User sessions
Server process
Server process
Server process
Listener
Server process
Server process
Server process
Listener
UGA
6-2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Database User Accounts
6-3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Predefined Administrative Accounts
• SYS:
– Owns the data dictionary and the Automatic Workload
Repository (AWR)
– Used for startup and shutdown of the database instance
• SYSTEM: Owns additional administrative tables and views
• SYSBACKUP: Facilitates Oracle Recovery Manager
(RMAN) backup and recovery operations
• SYSDG: Facilitates Oracle Data Guard operations
• SYSKM: Facilitates Transparent Data Encryption wallet
operations
6-5 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Administrative Privileges
Privilege Description
SYSDG Data Guard operations by using the Data Guard Broker or the
DGMGRL command-line interface
6-6 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Protecting Privileged Accounts
SYSDBA
6-7 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Authenticating Users
6-8 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Administrator Authentication
Select “Alter
Account.”
Password is expired
and account is locked.
Deselect “Account
Locked.”
HR_DBA
GRANT
Privilege
Object
REVOKE CREATE
TABLE FROM joe;
• Roles:
– Used to group together privileges and roles
– Facilitate granting of multiple privileges or roles to users
• Benefits of roles:
– Easier privilege management
– Dynamic privilege management
– Selective availability of privileges
Users
Jenny David Rachel
Insert Select
employees. employees.
APPS PUBLIC
role SELECT ANY TABLE
Sales
module Used privileges Unused privileges
Password
Password complexity
history verification
User Setting up
profiles
Note: Do not use profiles that cause the SYS, SYSMAN, and DBSNMP
passwords to expire and the accounts to be locked.
A database role:
a. Can be enabled or disabled
b. Can consist of system and object privileges
c. Is owned by its creator
d. Cannot be protected by a password
7-2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
How Table Data Is Stored
Columns Blocks
Table A Table B
Rows
Segment Segment
Table
Tablespace
7-3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Database Block: Contents
Block header
Growth
Free space
Row data
7-4 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Exploring the Storage Structure
7-5 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Creating a New Tablespace
7-6 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Creating a New Tablespace
7-7 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Creating a New Tablespace
7-8 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Creating a New Tablespace
7-9 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Creating a New Tablespace
Example:
SQL> ALTER SYSTEM
2 SET DB_CREATE_FILE_DEST='/u01/app/oracle/oradata';
SQL> CREATE TABLESPACE tbs_1;
Database
SYSTEM INVENTORY
tablespace tablespace
MOVE
ONLINE
1
ASM Storage 2 File System Storage
MOVE
ONLINE
8-2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Space Management: Overview
8-3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Block Space Management
PCTFREE = 10
FS2
FS3
FS1
FS1
FS2
Inserts, Deletes Deletes
updates FS3
FS4
Full block Full block
8-4 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Row Chaining and Migration
Example:
• On update: Row length increases,
exceeding the available free space Old
in the block.
• Data needs to be stored in a new block. Original block
• Original physical identifier of row with pointer
(ROWID) is preserved. to migrated
row
• The Oracle Database server needs
to read two blocks to retrieve data.
• The Segment Advisor finds segments New data
containing the migrated rows.
• There is automatic coalescing of fragmented
free space inside the block.
8-5 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Quiz
8-7 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Free Space Management Within Segments
Extent
Segment
8-8 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Types of Segments
8-9 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Allocating Extents
Header
PCTFREE
=0
Uncompressed
Free
data
space
Compressed
data
Data block
Inserts are PCTFREE reached Inserts are again PCTFREE reached
uncompressed. triggers compression. uncompressed. triggers compression.
• Is enabled with
CREATE TABLE … ROW STORE COMPRESS ADVANCED
…;
• Is recommended for active OLTP environments
G Y
Y Y Y Y Y Y
G Y G G Y G
G Y Y G G Y Y G
Uncompressed OLTP compression with symbol table at
block the beginning of the block
MMON
HWM
HWM
DML operations and queries can be issued during compaction.
2 ALTER TABLE employees SHRINK SPACE;
HWM
DML operations are blocked when the HWM is adjusted.
Index
Table Shrink
DBA
A resumable statement:
• Enables you to suspend large operations instead of
receiving an error
• Gives you a chance to fix the problem while the operation
is suspended, rather than starting over
• Is suspended for the following conditions:
– Out of space
– Maximum extents reached
– Space quota exceeded
• A resumable statement can be suspended and resumed
multiple times.
1 SQL statement
Full table
2 Suspended
Continue
SQL 3 4
Optionally
operation
5 Table AFTER
with free SUSPEND Abort
space trigger
9-2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Undo Data: Overview
User
9-3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Transactions and Undo Data
Undo
segment
Data in Undo “old” data
buffer cache in undo tablespace
9-5 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Storing Undo Information
9-6 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Comparing Undo Data and Redo Data
Undo Redo
Undo
segment
Redo log
files
9-7 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Managing Undo
9-8 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Configuring Undo Retention
DBA
9-9 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Categories of Undo
Category Description
Retention guarantee:
15 minutes
Undo data in
undo
tablespace
SELECT statements A transaction will fail
running 15 minutes or less if it generates more undo
are always satisfied. than there is space.
Note: This example is based on an UNDO_RETENTION setting of 900 seconds (15
minutes).
• Rationale:
– Supporting Flashback operations
– Limiting tablespace growth
• Steps:
1. Run regular workload.
2. Self-tuning mechanism establishes minimum required size.
3. (Optional) Use the Enterprise Manager Cloud Control Undo
Advisor, which calculates required size for future growth.
4. (Optional) Change undo tablespace to a fixed size.
Stored in Stored in
temporary user
tablespace tablespace
SQL>
Transaction 1 Transaction 2
SQL> UPDATE employees SQL> UPDATE employees
2 SET salary=salary+100 2 SET salary=salary*1.1
3 WHERE employee_id=100; 3 WHERE employee_id=100;
Transaction 1 Transaction 2
SQL> UPDATE employees SQL> UPDATE employees
2 SET salary=salary+100 2 SET salary=salary*1.1
3 WHERE employee_id=100; 3 WHERE employee_id=101;
Transaction 1 Transaction 2
SQL> UPDATE employees SQL> UPDATE employees
2 SET salary=salary*1.1 2 SET salary=salary*1.1
3 WHERE employee_id= 107; 3 WHERE employee_id= 106;
1 row updated. 1 row updated.
• Uncommitted changes
• Long-running transactions
• Unnecessarily high locking levels
Result:
Transaction 1 Transaction 2
UPDATE employees UPDATE employees
SET salary = salary x 1.1 9:00 SET manager = 1342
WHERE employee_id = 1000; WHERE employee_id = 2000;
UPDATE employees UPDATE employees
SET salary = salary x 1.1 9:15 SET manager = 1342
WHERE employee_id = 2000; WHERE employee_id = 1000;
ORA-00060:
Deadlock detected while 9:16
waiting for resource
1 Enable unified
auditing. $ORACLE_
AUDIT_ADMIN User
HOME
executes
2 Configure auditing command.
(audit policies).
Database
Server
process
Audit
Generates audit trail
AUDIT_VIEWER settings
3 Review audit
information. GEN0
Audit table
4 Maintain audit Audit records in
trail. SGA in-memory queues
1 Background process
GEN0
3 Manual flush
SQL> EXEC SYS.DBMS_AUDIT_MGMT.FLUSH_UNIFIED_AUDIT_TRAIL
View
Read-only AUDSYS table
SYS.UNIFIED_AUDIT_TRAIL
Method Description
Fine-grained audit policies Define specific conditions that must be met for
auditing to take place
• Actions:
CREATE AUDIT POLICY audit_actions_pol2
ACTIONS AUDIT, ALTER TRIGGER
• Roles:
CREATE AUDIT POLICY audit_role_pol3
ROLES mgr_role
DBMS_AUDIT_MGMT.SET_AUDIT_TRAIL_PROPERTY
Policy: AUDIT_EMPS_SALARY
SELECT name, salary
FROM employees
WHERE
department_id = 10; employees
dbms_fga.add_policy (
• Defines: object_schema => 'HR',
object_name => 'EMPLOYEES',
– Audit criteria policy_name => 'audit_emps_salary',
– Audit action audit_condition=> 'department_id=10',
audit_column => 'SALARY,COMMISSION_PCT',
• Is created with handler_schema => 'secure',
DBMS_FGA handler_module => 'log_emps_salary',
.ADD_POLICY enable => TRUE,
statement_types => 'SELECT,UPDATE');
Oracle LogMiner
Control
files
CKPT
SCN:
SCN:129 SCN:143 102-143
Undo
SCN: 99
Control Redo log
Data files files group
Transactions
Archived
log Archived
log Online
Redo log
2 4
1 3 5
Restored Data files containing
data files committed and uncommitted Recovered
transactions data files
Archived
log Archived
X
log Online
Redo log X
Changes applied to point in time (PIT) Database
opened Undo applied
2
4 5
1 3 6
Restored data Data files containing
committed and PIT-recovered
files from as far
uncommitted data files
back as necessary
transactions up to PIT
Best One copy on each disk group At least two copies, each on separate disk
Practice (such as +DATA and +FRA) (at least one on separate disk controller)
Steps to No additional control file 1. Alter the SPFILE with the ALTER
create copies required SYSTEM SET control_files
additional command.
control 2. Shut down the database.
files 3. Copy control file to a new location.
4. Open the database and verify the
addition of the new control file.
Archiver
(ARCn)
Online redo Archived
log files redo log files
Archiver (ARCn):
SGA
• Is an optional background
process
• Automatically archives online Redo log buffer
ARCn
Archiver process
Backup
Backup
with
to SBT RMAN third-
Control channel
file party
media
Target database manager
Media Management
(Example: Oracle Secure Backup)
Oracle Backup to Tape
Secure
Non database files
Backup
A user-managed scenario:
• Is a manual process of tracking backup needs and status
• Typically uses your own written scripts
• Requires that database files be put in the correct mode for
backup
• Relies on operating system commands to make backups
of files
Data file #6
Image copies
(Duplicate data and log files in OS format)
Best practice
Backup
pieces
Change
tracking Recovery
Data files file area
Full backup
+ daily incremental
= new “full” backup
+ daily archived logs for recovery
1
$ rman target /
2 RMAN> CONFIGURE …
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
3
Control
Control Archived redo SPFILE
Data files filesfile log file
To open a database:
• All control files must be present and synchronized
• All online data files must be present and synchronized
• At least one member of each redo log group must be
present
OPEN
STARTUP
MOUNT
NOMOUNT
SHUTDOWN
If a member of a redo log file group is lost and if the group still
has at least one member, note the following results:
• Normal operation of the instance is not affected.
• You receive a message in the alert log notifying you that a
member cannot be found.
• You can restore the missing log file by dropping the lost
redo log member and adding a new member.
• If the group with the missing log file has been archived,
you can clear the log group to re-create the missing file.
SQL*Loader
expdp impdp Other clients
(sqlldr)
Data Pump
DBMS_DATAPUMP
Data/Metadata Movement Engine
Oracle Oracle
Loader DataPump Direct Path API DBMS_METADATA
Metadata API
External Table API
Data Pump offers many benefits and many features, such as:
• Fine-grained object and data selection
• Explicit specification of database version
• Parallel execution
• Estimation of export job space consumption
• Network mode in a distributed environment
• Remapping capabilities
• Data sampling and metadata compression
• Compression of data during a Data Pump export
• Security through encryption
• Ability to export XMLType data as CLOBs
• Legacy mode to support old import and export files
Source Target
Data Pump Server
job process
Database Database
Master Dump Dump Master
table file set file set table
“Network mode”
impdp
client
$ impdp hr DIRECTORY=DATA_PUMP_DIR \
DUMPFILE=HR_SCHEMA.DMP \
PARALLEL=1 \
CONTENT=ALL \
TABLES="EMPLOYEES" \
LOGFILE=DATA_PUMP_DIR:import_hr_employees.log \
JOB_NAME=importHR \
TRANSFORM=STORAGE:n
REMAP_TABLE = 'EMPLOYEES':'EMP'
SQL*Loader Rejected
Field processing
Discarded Accepted
Record selection
Selected
Bad
Oracle server file
Discard file Rejected
Inserted
(optional)
Log file
Table
HWM
Always generates redo entries Generates redo only under specific conditions
Enforces all constraints Enforces only PRIMARY KEY, UNIQUE, and NOT NULL
Can load into clustered tables Does not load into clusters
Allows other users to modify tables during Prevents other users from making changes to tables during
load operation load operation
Maintains index entries on each insert Merges new index entries at the end of the load
$ sqlldr hr TABLE=test
test.log file
• SQL*Loader control file options
• Create external table statement
test_%p.log_xt file
test.dat file hr.test table • Load result
(Text)
ext_table
(Metadata Only)
ORACLE_DATAPUMP
driver
Database (Binary)
Automatic Automatic
Workload Diagnostic
Repository Efficient Repository
In-memory 60 minutes
statistics MMON Snapshots
SGA
AWR
External clients
EM SQL*Plus …
SGA
Efficient V$ DBA_*
in-memory AWR
statistics snapshots
collection MMON
Self-tuning … Self-tuning
ADDM
Internal clients component component
ADDM finds
MMON
top problems.
SYSAUX
SGA
6:00 AM
Snapshot 1
In-memory 7:00 AM
Snapshot 2
statistics 8:00 AM Snapshot 3
9:00 AM
Snapshot 4
9:30 AM
Relevant period
in the past
DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE ( -
start_snap_id IN NUMBER,
end_snap_id IN NUMBER,
baseline_name IN VARCHAR2);
• Retention period
– Default: Eight days
– Consider storage needs
• Collection interval
– Default: 60 minutes
– Consider storage needs
and performance impact
• Collection level
– Basic (disables most ADDM functionality)
– Typical (recommended)
– All (adds additional SQL tuning information to snapshots)
STATISTICS_LEVEL
Additional statistics
Self-tuning Recommended
for manual
capabilities disabled default value
SQL diagnostics
Snapshots
EM ADDM
ADDM results
AWR
Segment Advisor
Space
Undo Advisor
Enterprise Manager
Server
alerts
Oracle queue.
instance
Metric exceeds
threshold.
AWR
Metric based
MMON
DBA_OUTSTANDING_ALERTS DBA_ALERT_HISTORY
Memory
allocation
issues
Input/output Resource
device contention
contention
?
DBA
Application Network
code bottlenecks
problems
• Investment options
• System architecture
• Scalability
• Application design principles
• Workload testing, modeling, and implementation
• Deploying new applications
800 MB
Memory Target
640 MB
Memory Target
Oracle recommends the use of AMM unless you have special requirements.
MEMORY_MAX_TARGET
PGA_AGGREGATE_TARGET
SGA_TARGET
PGA_AGGREGATE_LIMIT
• This enables ASMM.
• Changing SGA_TARGET Child parameters:
affects only automatically • Providing minimum values
sized components. Others
• Automatic change of size only
LOG_BUFFER with autotuned parameters
SHARED_POOL_SIZE RESULT_CACHE_SIZE
DB_CACHE_SIZE
LARGE_POOL_SIZE DB_KEEP_CACHE_SIZE
JAVA_POOL_SIZE DB_RECYCLE_CACHE_SIZE
STREAMS_POOL_SIZE DB_nK_CACHE_SIZE
Buffer cache
Buffer cache
SGA_TARGET = 8G
DB_CACHE_SIZE = 0
JAVA_POOL_SIZE = 0
LARGE_POOL_SIZE = 0
SHARED_POOL_SIZE = 0
STREAMS_POOL_SIZE = 0
Server PGA
process Private Cursor
Session Work
UGA SQL and SQL
memory area
areas area
Dedicated
connections UGA
Shared
PGA
server Shared pool
or UGA
Shared server large pool
connections
Instance/Database Disk
V$DATABASE V$DATAFILE
V$INSTANCE V$FILESTAT
V$PARAMETER V$LOG
V$SPPARAMETER V$LOG_HISTORY
V$SYSTEM_PARAMETER V$DBFILE
V$PROCESS V$TEMPFILE
V$BGPROCESS V$TEMPSEG_USAGE
V$PX_PROCESS_SYSSTAT V$SEGMENT_STATISTICS
V$SYSTEM_EVENT
Contention
Memory V$LOCK
V$BUFFER_POOL_STATISTICS V$UNDOSTAT
V$LIBRARYCACHE V$WAITSTAT
V$SGAINFO V$LATCH
V$PGASTAT
V$EVENT_NAME
V$SYSTEM_EVENT
• EVENT_NUMBER
• EVENT
• EVENT_ID
• TOTAL_WAITS
• NAME
• TOTAL_TIMEOUTS
• PARAMETER1
• TIME_WAITED
• PARAMETER2
• AVERAGE_WAIT
• PARAMETER3
• TIME_WAITED_MICRO
• WAIT_CLASS
Workload specification
Recommendations
- SQL statement
- Indexes
- SQL Tuning Set
- Materialized views
- SQL cache contents
- Materialized view logs
- Statistics
- Partitioning
- Schema name
SQL Access
Advisor
Database
Resource Manager
More resources
OLTP users
Resource
consumer User groups or sessions with
group
similar resource needs
SYSGROUP 100%
CONSGROUP1 80%
CONSGROUP2 20%
OTHER_GROUPS 100%
PARALLEL_DEGREE_LIMIT_MTH: PARALLEL_DEGREE_LIMIT_ABSOLUTE
Limiting degree of parallelism of
any operation
ACTIVE_SESS_POOL_MTH: ACTIVE_SESS_POOL_ABSOLUTE
Limiting number of active
sessions, queuing inactive ones
QUEUING_MTH: Controlling FIFO_TIMEOUT
queues, how inactive sessions
enter active session pool
EMPHASIS RATIO
The value specifies the maximum The value specifies a number that indicates
percentage of CPU resources a the ratio of CPU resources to be allocated to
consumer group can use. the consumer group.
You can allocate resources for up to You can specify values for only one level.
eight different levels.
The sum of percentages at any given You must use integer values, but there is no
level must be less than or equal to 100. limit on the sum of values.
Default value is NULL. Default value is NULL.
Sess3 Sess8
Sess9
Sess1 Sess2 Sess6 Sess7
DSS
active
session
queue
OLTP users DSS users
ACTIVE_SESS_POOL_P1=5 ACTIVE_SESS_POOL_P1=3
DBMS_RESOURCE_MANAGER.UPDATE_PLAN_DIRECTIVE
(PLAN => 'DAY_PLAN',
GROUP_OR_SUBPLAN => 'APPUSER',
COMMENT => 'Limit Idle Time Example',
NEW_MAX_IDLE_TIME => 600,
NEW_MAX_IDLE_BLOCKER_TIME => 300);
EXEC DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE( -
plan => 'db_consolidation_plan',
group_or_subplan => 'App_1',
mgmt_p1 => 50,
max_utilization_limit => 60);
• Two approaches:
– Over-provisioning: The sum of the CPU limit for each
instance exceeds the actual number of CPUs.
– Partitioning: The sum of the CPU limit for each instance
equals the actual number of CPUs.
32 16 Total number
Instance D of CPUs = 16
Instance D
24 12 Instance C
Instance C Instance B
16 Total number
8
of CPUs = 16
Instance B
8 4 Instance A
Instance A
Manage throttling:
SELECT begin_time, consumer_group_name,
cpu_consumed_time, cpu_wait_time
FROM v$rsrcmgrmetric_history
ORDER BY begin_time;
SELECT name, consumed_cpu_time, cpu_wait_time
FROM v$rsrc_consumer_group;
DBA_RSRC_CONSUMER_GROUP_PRIVS Users/roles
DBA_USERS Column
INITIAL_RSRC_CONSUMER_GROUP
DBA_RSRC_MANAGER_SYSTEM_PRIVS Users/roles
Generating an Rebuilding an
Starting the batch
hourly report on index when
load as soon as the file
invalid server finished rebuilding
arrives on the file system access attempts the current index
BEGIN
sys.dbms_scheduler.create_job(
job_name => '"HR"."CREATE_LOG_TABLE_JOB"',
job_type => 'PLSQL_BLOCK', job_action => 'begin
execute immediate (''create table session_history(
snap_time TIMESTAMP WITH LOCAL TIME ZONE,
num_sessions NUMBER)''); end;',
start_date => systimestamp at time zone
'America/New_York',
job_class => 'DEFAULT_JOB_CLASS',
comments => 'Create the SESSION_HISTORY table',
auto_drop => FALSE, enabled => TRUE);
END;
Job
Program Schedule
attributes
Job
Arguments
Schedule
Time
• Calendaring expression Event
• Date-time expression
BEGIN
DBMS_SCHEDULER.CREATE_JOB(
job_name=>'HR.DO_BACKUP',
job_type => 'EXECUTABLE',
job_action =>
'/home/usr/dba/rman/nightly_incr.sh',
start_date=> SYSDATE,
repeat_interval=>'FREQ=DAILY;BYHOUR=23',
/* next night at 11:00 PM */
comments => 'Nightly incremental backups');
END;
/
Oracle Database
Scheduler
Event ADT
(Abstract
Application Queue
Data Type)
Example: Create a job that runs if a batch load data file arrives
on the file system before 9:00 AM.
BEGIN
DBMS_SCHEDULER.CREATE_JOB(
job_name=>'ADMIN.PERFORM_DATA_LOAD',
job_type => 'EXECUTABLE',
job_action => '/loaddir/start_my_load.sh',
start_date => SYSTIMESTAMP,
event_condition => 'tab.user_data.object_owner =
''HR'' and tab.user_data.object_name = ''DATA.TXT''
and tab.user_data.event_type = ''FILE_ARRIVAL''
and tab.user_data.event_timestamp < 9 ',
queue_spec => 'HR.LOAD_JOB_EVENT_Q');
END;
Event types:
• User-generated or application-generated events
• Scheduler-generated events
Events raised by Scheduler jobs:
• JOB_STARTED • JOB_SCH_LIM_REACHED
• JOB_SUCCEEDED • JOB_DISABLED
• JOB_FAILED • JOB_CHAIN_STALLED
• JOB_BROKEN • JOB_ALL_EVENTS
• JOB_COMPLETED • JOB_RUN_COMPLETED
• JOB_STOPPED • JOB_OVER_MAX_DUR
Example of raising an event:
DBMS_SCHEDULER.SET_ATTRIBUTE('hr.do_backup',
'raise_events', DBMS_SCHEDULER.JOB_FAILED);
DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION (
job_name IN VARCHAR2, Comma-separated list of
recipients IN VARCHAR2, email addresses
sender IN VARCHAR2 DEFAULT NULL,
subject IN VARCHAR2
DEFAULT dbms_scheduler.default_notification_subject,
body IN VARCHAR2
DEFAULT dbms_scheduler.default_notification_body,
events IN VARCHAR2 Mandatory comma-separated list
DEFAULT 'JOB_FAILED,JOB_BROKEN,JOB_SCH_LIM_REACHED,
JOB_CHAIN_STALLED,JOB_OVER_MAX_DUR',
filter_condition IN VARCHAR2 DEFAULT NULL);
DBMS_SCHEDULER.REMOVE_JOB_EMAIL_NOTIFICATION (
job_name IN VARCHAR2,
recipients IN VARCHAR2 DEFAULT NULL,
events IN VARCHAR2 DEFAULT NULL);
Dependency scheduling
START
Job LOAD_DATA_EVT 1 DO_BULK_LOAD 2
STOP_WHEN_
DISK_FULL_EVT 5 3
Schedule REBUILD_INDX
Run_reports
END
(HR.GEN_REPORTS)
4
BULK_LOAD_CHAIN
Resource DB
consumer service Resource Window
group name plan group
Job class
Default: DEFAULT_JOB_CLASS
Scheduler windows:
• Can start jobs or change resource allocation among jobs
for various time periods
• One active at a time
• Created with the CREATE_WINDOW procedure
Resource
Resource
plan
consumer group
Window
Job class
Job
Prioritizing jobs:
• At the class level (via resource plans)
• At the job level (with the job priority attribute)
• Not guaranteed for jobs in different job classes
Job Priority
Job1 Job2
Job1 1
APPL_JOBS
Job3 Job2 2
ADMIN_JOBS Job4 5
DECLARE
newjob sys.job;
newjobarr sys.job_array;
(… continued)
Select the statements that are true about the Oracle Scheduler.
a. Creating remote database jobs is a manual task requiring
the use of OS-specific commands.
b. A Scheduler credential is an object with which to
authenticate with the host operating system for file access.
c. You can specify several targets on which your jobs should
execute and monitor them from the database on which
they were created.
ssh access
Enterprise - High Advanced Analytics, Advanced Compression, Cloud Management for Oracle Database,
Performance Advanced Security, Database Vault, Label Database Lifecycle Management, Data
Security, Multitenant, OLAP, Partitioning, Real Masking and Subsetting, Diagnostics, Tuning
Application Testing, Spatial and Graph
Enterprise - Active Data Guard, Advanced Analytics, Advanced Cloud Management for Oracle Database,
Extreme Compression, Advanced Security, Database In- Database Lifecycle Management, Data
Performance Memory, Database Vault, Label Security, Masking and Subsetting, Diagnostics, Tuning
Multitenant, OLAP, Partitioning, Real Application
Clusters, Real Application Testing, Spatial and
Graph
1. Display the Sign In to Oracle Cloud page by clicking the My Services URL
link in your Welcome email or by following these instructions:
a. Open your web browser and go to the Oracle Cloud website.
b. Click Sign In.
c. In the My Services box, select the data center where your services are located.
d. Click Sign In to My Services.
2. On the Sign In to Oracle Cloud page, enter your username, password, and
the name of your identity domain. Then, click Sign In.
3. On the My Services Dashboard, click the navigation menu in the top corner
and then click Oracle Database Cloud Service.
4. If a Welcome page is displayed, view the list of database deployments by
clicking Services next to “Database Cloud Service.”
Request Database
for Ready for
Service Allocate Allocate Provision Set Keys Install & Configure Configure Configure Use
Compute Storage OS & Configure Backups Tools Access
Privileges Database
Expand the action menu on the Database Cloud Service console to access
tools:
Web application to Application
monitor the Oracle development using a
database web browser.
Enterprise Manager
Database Control 11g Add SSH public keys
Enterprise Manager for the opc and
Database Express 12c oracle users
Scale the compute shape or storage from the Action menu in the Oracle
Database Cloud Service console:
Action
Scale Up Select a new compute shape.
Add raw storage to the database
deployment.
Check patch
prerequisities
Apply a patch
A-2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Working with Oracle Support
A-3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Using My Oracle Support
A-4 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Researching an Issue
A-6 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Logging Service Requests
A-8 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Accessing My Oracle Support Community
Kinds of patches
• Interim patches
– For specific issues
– No regression testing
• Security Patch Updates (SPUs)
– Critical security issues
– Regression testing
– Does not advance version number
• Patch Set Updates (PSUs)
• Patch releases
View critical
1 error alerts in
Enterprise Manager.