You access Oracle Enterprise Manager Cloud Control 12c as the sysman user with the Oracle123 password and select Summary as your home page.. Practice 1-1: Accessing Enterprise Manager
Trang 1Oracle Database 12c: New
Features for Administrators
Trang 2Copyright © 2013, Oracle and/or its affiliates All rights reserved
Disclaimer
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 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 document in whole or in part without the express authorization
of Oracle
The information contained in this document is subject to change without notice If you find any 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-free
Restricted Rights Notice
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:
U.S GOVERNMENT RIGHTS
The U.S Government’s rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted
by the terms of the applicable Oracle license agreement and/or the applicable U.S Government contract
Trademark Notice
Oracle and Java are registered trademarks of Oracle and/or its affiliates Other names may be trademarks of their respective
owners
Authors
Dominique Jeunot, Jean-François Verrier
Technical Contributors and Reviewers
James Spiller, Donna Keesling, Maria Billings, Lachlan Williams, Peter Fusek, Dimpi Sarmah, Branislav Valny, Christina Nayagam, Frank Fu, Joel Goodman, Gerlinde Frenzen, Harald Van Breederode, Herbert Bradbury, Hermann Baer, Jim Stenoish, Malareddy Goutam, Patricia
Mcelroy, Paul Needham, Puneet Sangar, Robert Mcguirk, Sailaja Pasupuleti, Sean Kim,
Sharath Bhujani, Steven Wertheimer, Uwe Hesse, Vimala Jacob
This book was published using: Oracle Tutor
Trang 3Copyright © 2013, Oracle and/or its affiliates All rights reserved
Table of Contents
Practices for Lesson 1: Enterprise Manager Cloud Control and Other Tools 1-1
Practices for Lesson 1: Overview 1-2
Practice 1-1: Accessing Enterprise Manager 1-3
Practice 1-2: Adding a Database Instance as a New Target Monitored by EM Cloud Control 1-6
Practice 1-3: Creating New Named Credentials 1-9
Practice 1-4: Testing the Named Credential 1-11
Practices for Lesson 2: Basics of Multitenant Container Database and Pluggable Databases 2-1
Practices for Lesson 2: Overview 2-2
Practice 2-1: Exploring CDB Architecture and Structures 2-3
Practices for Lesson 3: Creating a Multitenant Container Database and Pluggable Databases 3-1
Practices for Lesson 3 3-2
Practice 3-1: Creating a New CDB 3-3
Practice 3-2: Exploring CDB and PDB Structures 3-7
Practice 3-3: Creating a PDB from Seed 3-19
Practice 3-4: Cloning PDB Within the Same CDB 3-27
Practice 3-5: Plugging a Non-CDB into a CDB 3-38
Practice 3-6: Merging All PDBs of CDBs into a Single CDB 3-45
Practice 3-7: Dropping a PDB (optional) 3-50
Practices for Lesson 4: Managing a Multitenant Container Database and Pluggable Databases 4-1
Practices for Lesson 4 4-2
Practice 4-1: Shutdown and Startup of the CDB 4-3
Practice 4-2: Closing and Opening a PDB 4-8
Practice 4-3: Creating After Startup Trigger to Open All PDBs 4-14
Practice 4-4: Changing PDBs' Open Mode 4-16
Practice 4-5: Instance Parameter Changes: Impact on PDBs (optional) 4-18
Practices for Lesson 5: Managing Tablespaces and Users in a CDB and PDBs 5-1
Practices for Lesson 5 5-2
Practice 5-1: Managing Tablespaces 5-3
Practice 5-2: Managing Common and Local Users 5-11
Practice 5-3: Managing Local and Common Roles 5-19
Practice 5-4: Managing Local and Common Privileges 5-27
Practices for Lesson 6: Backup, Recovery, Flashback CDB and PDBs 6-1
Practices for Lesson 6 6-2
Practice 6-1: Cold CDB Backup 6-3
Practice 6-2: RMAN Whole CDB Backup 6-5
Practice 6-3: RMAN CDB / PDB Backup 6-8
Practice 6-4: RMAN Recovery from SYSTEM PDB Data File Loss 6-10
Practice 6-5: RMAN Recovery from Non-Essential PDB Data File Loss 6-14
Practice 6-6: SQL PDB Hot Backup (optional) 6-18
Practice 6-7: SQL Control File Backup (optional) 6-20
Practice 6-8: RMAN Recovery from Control File Loss (optional) 6-21
Practice 6-9: RMAN Recovery from Redo Log File Member Loss (optional) 6-26
Practice 6-10: RMAN Recovery from SYSTEM Root Data File Loss (optional) 6-29
Practice 6-11: RMAN Recovery from Non-Essential Root Data File Loss (optional) 6-33
Practice 6-12: PITR on PDB Tablespaces (optional) 6-35
Practice 6-13: Flashback from Common User Drop (optional) 6-42
Trang 4Practices for Lesson 7: Heat Map, Automatic Data Optimization and Online Datafile Move 7-1
Practices for Lesson 7 7-2
Practice 7-1: Enabling Heat Map 7-3
Practice 7-2: Automatic Data Optimization – Creating a TIER Policy 7-5
Practice 7-3: Automatic Data Optimization – Creating a COMPRESS Policy 7-14
Practice 7-4: Cleanup ADO Policies and Heat Map Statistics 7-26
Practice 7-5: Moving Data File Online 7-28
Practices for Lesson 8: In-Database Archiving and Temporal Validity 8-1
Practices for Lesson 8 8-2
Practice 8-1: In-Database Archiving – Row-archival 8-3
Practice 8-2: Temporal Validity 8-8
Practice 8-3: Collecting User Context in FDA History Tables (optional) 8-18
Practice 8-4: Cleaning Up FDA 8-24
Practices for Lesson 9: Auditing 9-1
Practices for Lesson 9 9-2
Practice 9-1: Enabling Unified Auditing 9-3
Practice 9-2: Auditing Data Pump Export 9-9
Practice 9-3: Auditing RMAN Backups 9-13
Practices for Lesson 10: Privileges 10-1
Practices for Lesson 10 10-2
Practice 10-1: Manage Password File with SYSBACKUP Entry 10-3
Practice 10-2: Capturing Privileges 10-8
Practice 10-3: Capture Privileges Used Through Roles (Optional) 10-17 Practice 10-4: Capture Privileges Used In Contexts (Optional) 10-21 Practice 10-5: Use INHERIT PRIVILEGES Privilege 10-24 Practice 10-6: INHERIT PRIVILEGES Privilege and BEQUEATH Views 10-27
Practices for Lesson 11: Oracle Data Redaction 11-1
Practices for Lesson 11 11-2
Practice 11-1: Redacting Protected Column Values with FULL Redaction 11-3
Practice 11-2: Redacting Protected Column Values with PARTIAL Redaction (optional) 11-7
Practice 11-3: Cleaning Up Redaction Policies 11-10
Practices for Lesson 12: Recovery Manager New Features and Temporal History Enhancements 12-1
Practices for Lesson 12 12-2
Practice 12-1: Using SYSBACKUP in RMAN 12-3
Practice 12-2: Recovering a Table by Using Table Recovery 12-9
Practices for Lesson 13: Real-Time Database Operation Monitoring 13-1
Practices for Lesson 13: Overview 13-2
Practice 13-1: Starting Enterprise Manager Database Express 13-3
Practice 13-2: Identifying and Starting Database Operations 13-7
Practice 13-3: Identifying and Starting Database Load Operations (Optional) 13-14 Practice 13-4: Cleaning Up 13-16
Practices for Lesson 14: Schema and Data Changes Management 14-1
Practices for Lesson 14 14-2
Practice 14-1: Using Schema Change Plans 14-3
Practices for Lesson 15: SQL Tuning Enhancements 15-1
Practices for Lesson 15 15-2
Practice 15-1: Using Dynamic Plans 15-3
Trang 5Copyright © 2013, Oracle and/or its affiliates All rights reserved
Practice 15-2: Using Re-optimization 15-8
Practices for Lesson 16: Emergency Monitoring and Compare Period ADDM 16-1
Practices for Lesson 16 16-2
Practice 16-1: Using Emergency Monitoring 16-3
Practice 16-2: Cleaning Up 16-8
Practice 16-3: Using Compare Period ADDM (optional) 16-9
Practices for Lesson 17: Resource Manager and Other Performance Enhancements 17-1
Practices for Lesson 17 17-2
Practice 17-1: Using CDB Resource Manager Plans and Directives 17-3
Practice 17-2: Using Multi-Process Multi-Threaded Architecture 17-14
Practices for Lesson 18: Tables, Indexes and Online Operations 18-1
Practices for Lesson 18 18-2
Practice 18-1: Using Invisible Table Columns 18-3
Practice 18-2: Advanced Row Compression 18-7
Practices for Lesson 19: ADR and Network Enhancements 19-1
Practices for Lesson 19 19-2
Practice 19-1: Viewing ADR DDL Log File 19-3
Practices for Lesson 20: Oracle Data Pump, SQL*Loader, and External Tables 20-1
Practices for Lesson 20 20-2
Practice 20-1: Creating a New non-CDB orcl3 20-3
Practice 20-2: Exporting/Importing Databases in FULL TRANSPORTABLE Mode 20-5
Practice 20-3: Loading Data Using SQL*Loader Express Mode (Optional) 20-30
Practices for Lesson 21: Partitioning Enhancements 21-1
Practices for Lesson 21 21-2
Practice 21-1: Local and Global Partial Indexing on Partitioned Tables 21-3
Practices for Lesson 22: SQL Enhancements and Migration Assistant for Unicode 22-1
Practices for Lesson 22 22-2
Practice 22-1: Using 32K VARCHAR2 Data Type 22-3
Practice 22-2: Quering a Table Using a SQL Row-Limiting Clause 22-11
Trang 7Copyright © 2013, Oracle and/or its affiliates All rights reserved
Practices for Lesson 1:
Enterprise Manager Cloud Control and Other Tools
Trang 8Practices for Lesson 1: Overview
Practices Overview
Your system currently has Oracle Database 12c software installed, as well as three pre-created
database called orcl, orcl2 and cdb1
You act as an Enterprise Manager administrator You access Oracle Enterprise Manager Cloud
Control 12c as the sysman user with the Oracle123 password and select Summary as your
home page You start exploring some of the Oracle Enterprise Manager Cloud Control 12c
functionalities through the different menus and options And lastly, you will add the orcl
database as a monitored target
Trang 9Copyright © 2013, Oracle and/or its affiliates All rights reserved
Practice 1-1: Accessing Enterprise Manager
Overview
In this practice, you access Oracle Enterprise Manager Cloud Control 12c as the sysman user
with the Oracle123 password and select Summary as your home page
Assumptions
You reviewed the Oracle Enterprise Manager 12c: Console Overview and Customization
demonstration or have the equivalent navigation knowledge
Tasks
1 Click the Firefox icon on the top panel (toolbar region) above the desktop to open a browser
to access the Enterprise Manager Cloud Control console
2 Enter the URL for Cloud Control:
https://<em_server_hostname>.<domain>:7802/em In the current setup, use
https://localhost:7802/em If an error appears, you must first start the OMS, else proceed directly with step 3
a Start the Enterprise Manager Repository Database em12rep if not started already
$ oraenv ORACLE_SID = [orcl] ? em12rep
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is /u01/app/oracle
$ sqlplus / as sysdba
Connected to an idle instance
SQL> startup
ORACLE instance started
Total System Global Area 400846848 bytes
$ $OMS_HOME/bin/emctl start oms
Oracle Enterprise Manager Cloud Control 12c Release 2
Trang 10Copyright (c) 1996, 2012 Oracle Corporation All rights reserved
Starting Oracle Management Server
Starting WebTier
WebTier Successfully Started Oracle Management Server Successfully Started Oracle Management Server is Up
WARNING: Limit of open file descriptors is found to be 1024
The OMS has been started but it may run out of descriptors under heavy usage
For proper functioning of OMS, please set "ulimit -n" to be at least 4096
$
3 Most likely, you receive a Secure Connection Failed message and you need to add a
security exception Click Or you can add an exception
a At the end of the alert box, click I Understand the Risks
b At the bottom of the page, click Add Exception
c In the Add Security Exception pop-up window, click Get Certificate
d Confirm that “Permanently store this exception” is selected in your training environment
and click Confirm Security Exception
4 The Enterprise Manager Cloud Control console appears
Login
6 The first time a new user logs in to Enterprise Manager, a page asks you to accept the
license agreement You have to accept only once Then each time you will log in to
Enterprise Manager, you will not get the license agreement page
Trang 11Copyright © 2013, Oracle and/or its affiliates All rights reserved
7 The “Select Enterprise Manager Home Page” page appears with choices, such as:
Each choice has a Preview and a Select As My Home button
The page also has global menus with the following choices: Enterprise, Targets, Favorites,
History, and Search Target Name (next to the search entry field) Each of the menu items has drop-down menus with further choices
Preview any images that interest you
8 Click the “Select As My Home” next to the Summary choice After being successfully set, it
informs you how to change it
9 Question: How can you change your home selection after the initial setup?
Answer: SYSMAN > Select My Home… menu
Trang 12Practice 1-2: Adding a Database Instance as a New Target Monitored
by EM Cloud Control
Overview
Assumptions
As a prerequisite task, you must log in to Enterprise Manager Cloud Control as the SYSMAN
user with Oracle123 as the password
Tasks
First add the database instance orcl as a new target monitored by Oracle Enterprise Manager Cloud Control
Trang 13Copyright © 2013, Oracle and/or its affiliates All rights reserved
b In “Add Targets Manually”, choose “Add Non-Host Targets Using Guided Process
(Also Adds Related Targets)” Then in “Target Types”, choose “Oracle Database, Listener and Automatic Storage Management” for “Target Type” Click “Add Using Guided Discovery …” button
c In “Add Database Instance target: Specify Host”, click the magnifying glass to find your host Select your host, then click “Continue”
Trang 14d In the “Databases” list, deselect all databases except orcl Deselect the listener
connection once the target is being added Open a terminal window
$ oraenv ORACLE_SID = [oracle] ? orcl
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1 is /u01/app/oracle
$ sqlplus / as sysdba
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 -
64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> alter user dbsnmp identified by oracle_4U account unlock;
User altered
SQL> EXIT
$
e Click the “Test Connection” button You should receive the following message:
Trang 15Copyright © 2013, Oracle and/or its affiliates All rights reserved
Practice 1-3: Creating New Named Credentials
Overview
In this practice, you create the credorcl credential used for any connection as SYS user
sharable in the database instance orcl
Assumptions
You completed the practice 1-2 to add the orcl database instance as a new target monitored
by Enterprise Manager Cloud Control
Tasks
1 Navigate to Setup > Security > Named Credentials
a Enter the following values, then complete the Access Control section:
General Properties
to find orcl and select)
1) Click “Add Grant” then select the user SYS to be added in the Access Control list 2) Repeat this operation to add the user SYSTEM
By default, the selected users are granted the View privilege only
3) To grant Full privilege to SYS, select the SYS user and click “Change Privilege” Choose Full and click OK
Trang 164) To grant Edit privilege to SYSTEM, select the SYSTEM user and click “Change Privilege” Choose Edit and click OK
3 Test against the orcl database instance, click Test and Save until you get the following message: Confirmation Credential Operation Successful This means that the credential
was successful and saved
Trang 17Copyright © 2013, Oracle and/or its affiliates All rights reserved
Practice 1-4: Testing the Named Credential
Overview
In this practice, you test the credorcl named credential to connect to orcl database
Tasks
1 Test if the named credential works when you connect to the orcl target
Click Targets and then select Databases
credorcl is displayed
New to define new login username and password
5 As soon as you click the Logout button, the following screenshot is displayed
Choose “Logout of Enterprise Manager and all targets” and click the Logout button
Trang 19Copyright © 2013, Oracle and/or its affiliates All rights reserved
Practices for Lesson 2:
Basics of Multitenant Container Database and Pluggable Databases
Trang 20Practices for Lesson 2: Overview
Practices Overview
In previous Oracle Database versions, you used to create, configure, and manage non-CDBs
In Oracle Database 12c, you need to know how to create, configure, and manage multitenant
container databases (CDBs) and pluggable databases (PDBs)
In this practice, you will explore new types of databases and get familiar with the architecture and structures of multitenant container databases (CDBs) and pluggable databases (PDBs)
Trang 21Copyright © 2013, Oracle and/or its affiliates All rights reserved
Practice 2-1: Exploring CDB Architecture and Structures
oracle 390 1 0 18:05 ? 00:00:00 ora_w001_cdb1 oracle 2711 2686 0 18:32 pts/2 00:00:00 grep cdb1 oracle 27530 1 0 13:24 ? 00:00:02 ora_pmon_cdb1 oracle 27534 1 0 13:24 ? 00:00:04 ora_psp0_cdb1 oracle 27538 1 1 13:24 ? 00:05:01 ora_vktm_cdb1 oracle 27544 1 0 13:24 ? 00:00:00 ora_gen0_cdb1 oracle 27548 1 0 13:24 ? 00:00:00 ora_mman_cdb1 oracle 27556 1 0 13:24 ? 00:00:00 ora_diag_cdb1 oracle 27560 1 0 13:24 ? 00:00:00 ora_ofsd_cdb1 oracle 27564 1 0 13:24 ? 00:00:00 ora_dbrm_cdb1 oracle 27568 1 0 13:24 ? 00:00:11 ora_dia0_cdb1 oracle 27572 1 0 13:24 ? 00:00:02 ora_dbw0_cdb1 oracle 27576 1 0 13:24 ? 00:00:01 ora_lgwr_cdb1 oracle 27580 1 0 13:24 ? 00:00:03 ora_ckpt_cdb1 oracle 27584 1 0 13:24 ? 00:00:00 ora_smon_cdb1 oracle 27588 1 0 13:24 ? 00:00:00 ora_reco_cdb1 oracle 27592 1 0 13:24 ? 00:00:00 ora_lreg_cdb1 oracle 27596 1 0 13:24 ? 00:00:15 ora_mmon_cdb1 oracle 27600 1 0 13:24 ? 00:00:06 ora_mmnl_cdb1 oracle 27604 1 0 13:24 ? 00:00:00 ora_d000_cdb1 oracle 27608 1 0 13:24 ? 00:00:00 ora_s000_cdb1 oracle 27630 1 0 13:25 ? 00:00:00 ora_tmon_cdb1 oracle 27634 1 0 13:25 ? 00:00:00 ora_tt00_cdb1 oracle 27638 1 0 13:25 ? 00:00:00 ora_fbda_cdb1 oracle 27642 1 0 13:25 ? 00:00:00 ora_aqpc_cdb1 oracle 27651 1 0 13:25 ? 00:00:00 ora_p000_cdb1 oracle 27659 1 0 13:25 ? 00:00:00 ora_p001_cdb1 oracle 27666 1 0 13:25 ? 00:00:00 ora_p002_cdb1 oracle 27670 1 0 13:25 ? 00:00:00 ora_p003_cdb1 oracle 27682 1 0 13:25 ? 00:00:09 ora_cjq0_cdb1
Trang 22oracle 27734 1 0 13:25 ? 00:00:00 ora_qm01_cdb1 oracle 27738 1 0 13:25 ? 00:00:00 ora_q001_cdb1 oracle 27742 1 0 13:25 ? 00:00:00 ora_q002_cdb1 oracle 27750 1 0 13:25 ? 00:00:00 ora_smco_cdb1 oracle 31695 1 0 17:05 ? 00:00:00 ora_w002_cdb1
$
b Connect to the multitenant container database cdb1
$ oraenv ORACLE_SID = [orcl] ? cdb1
The Oracle base remains unchanged with value /u01/app/oracle
$ sqlplus / as sysdba
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 -
64bit Production With the Partitioning, OLAP, Data Mining, Real Application Testing
SQL>
c Check if the database is a multitenant container database
SQL> select name, cdb, con_id from v$database;
NAME CDB CON_ID - - - CDB1 YES 0 SQL>
d Check the instance name
SQL> select INSTANCE_NAME, STATUS, CON_ID from v$instance;
INSTANCE_NAME STATUS CON_ID - - - cdb1 OPEN 0
SQL> EXIT
$
2 Explore the services
a Start the listener if not yet started
Trang 23Copyright © 2013, Oracle and/or its affiliates All rights reserved
LSNRCTL for Linux: Version 12.1.0.0.2 - Production on
09-JUL-2012 02:57:38 Copyright (c) 1991, 2012, Oracle All rights reserved
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER
- Alias LISTENER Version TNSLSNR for Linux: Version 12.1.0.0.2
- Production Start Date 10-JUL-2012 00:15:19 Uptime 0 days 2 hr 42 min 19 sec Trace Level off
Security ON: Local OS Authentication SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.o
ra Listener Log File
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=yourserver)(PORT=5502
))(Security=(my_wallet_directory=/u01/app/oracle/admin/cdb1/xdb_wallet)) (Presentation=HTTP)(Session=RAW))
Services Summary
Service "cdb1" has 1 instance(s)
Instance "cdb1", status READY, has 1 handler(s) for this
service
Service "cdb1XDB" has 1 instance(s)
Instance "cdb1", status READY, has 1 handler(s) for this service
Service "em12rep" has 1 instance(s)
Instance "em12rep", status READY, has 1 handler(s) for this service
Service "em12repXDB" has 1 instance(s)
Instance "em12rep", status READY, has 1 handler(s) for this service
Service "orcl" has 1 instance(s)
Trang 24Instance "orcl", status READY, has 1 handler(s) for this service
Service "orcl2" has 1 instance(s)
Instance "orcl2", status READY, has 1 handler(s) for this service
Service "orcl2XDB" has 1 instance(s)
Instance "orcl2", status READY, has 1 handler(s) for this service
Service "orclXDB" has 1 instance(s)
Instance "orcl", status READY, has 1 handler(s) for this service
Service "pdb1_1" has 1 instance(s)
Instance "cdb1", status READY, has 1 handler(s) for this
service
The command completed successfully
$ The listener is already started If it were not started, you would use the following command
to start the listener:
$ lsnrctl start
LSNRCTL for Linux: Version 12.1.0.0.2 - Production on
09-JUL-2012 03:08:50 Copyright (c) 1991, 2012, Oracle All rights reserved
/u01/app/oracle/diag/tnslsnr/yourserver/listener/alert/log.xml
Listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=yourserver)(PORT=1521)
))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER
- Alias LISTENER
Trang 25Copyright © 2013, Oracle and/or its affiliates All rights reserved
Version TNSLSNR for Linux: Version 12.1.0.0.2
- Production Start Date 09-OCT-2012 03:08:50 Uptime 0 days 0 hr 0 min 0 sec Trace Level off
Security ON: Local OS Authentication SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.o
ra Listener Log File
/u01/app/oracle/diag/tnslsnr/yourserver/listener/alert/log.xml
Listening Endpoints Summary
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=yourserver)(PORT=1521)
)) The listener supports no services The command completed successfully
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) Services Summary
Service "cdb1" has 1 instance(s)
Instance "cdb1", status READY, has 1 handler(s) for this
service
Handler(s):
"DEDICATED" established:2 refused:0 state:ready LOCAL SERVER
Service "cdb1XDB" has 1 instance(s)
Instance "cdb1", status READY, has 1 handler(s) for this service
Trang 26(ADDRESS=(PROTOCOL=tcp)(HOST=yourserver)(PORT=29863))
Service "em12rep" has 1 instance(s)
Instance "em12rep", status READY, has 1 handler(s) for this service
Handler(s):
"DEDICATED" established:2748 refused:0 state:ready LOCAL SERVER
Service "em12repXDB" has 1 instance(s)
Instance "em12rep", status READY, has 1 handler(s) for this service
Service "orcl" has 1 instance(s)
Instance "orcl", status READY, has 1 handler(s) for this service
Handler(s):
"DEDICATED" established:251 refused:0 state:ready LOCAL SERVER
Service "orcl2" has 1 instance(s)
Instance "orcl2", status READY, has 1 handler(s) for this service
Handler(s):
"DEDICATED" established:4 refused:0 state:ready LOCAL SERVER
Service "orcl2XDB" has 1 instance(s)
Instance "orcl2", status READY, has 1 handler(s) for this service
Service "orclXDB" has 1 instance(s)
Instance "orcl", status READY, has 1 handler(s) for this service
Trang 27Copyright © 2013, Oracle and/or its affiliates All rights reserved
Instance "cdb1", status READY, has 1 handler(s) for this
SQL> col name format A20 SQL> select name, con_id from v$services;
NAME CON_ID - - pdb1_1 3 cdb1XDB 1 cdb1 1 SYS$BACKGROUND 1 SYS$USERS 1 SQL>
Notice that the PDB$SEED service is not listed No one should connect to this service
because there should be no operations performed on this container It is reserved as a
template to create other PDBs
3 Display the pluggable databases
a Use the new view V$PDBS
SQL> select CON_ID, NAME, OPEN_MODE from v$pdbs;
CON_ID NAME OPEN_MODE - - -
2 PDB$SEED READ ONLY
3 PDB1_1 READ WRITE SQL>
Notice that the seed PDB is in READ ONLY open mode
Trang 28b Use the new command SHOW CON_NAME and CON_ID to know which container you
are connected to
SQL> show con_name
CON_NAME - CDB$ROOT
SQL> show con_id
CON_ID -
1 SQL>
You can also use SYS_CONTEXT function to view the CON_NAME and CON_ID attributes
of your session context
SELECT sys_context('userenv','CON_NAME') from dual;
SELECT sys_context('userenv','CON_ID') from dual;
4 View some of the new family of views CDB_xxx:
SQL> col PDB_NAME format a8 SQL> col CON_ID format 99 SQL> select PDB_ID, PDB_NAME, DBID, GUID, CON_ID
2 from cdb_pdbs;
PDB_ID PDB_NAME DBID GUID CON_ID
-
3 PDB1_1 3624951709 C39AE2177B2E530EE043160200C043C3
1
2 PDB$SEED 4029862422 C2CBF2921BD1161FE04388AAE80AB141
1 SQL>
The PDB_ID number 2 is always assigned to the seed PDB because it is the second
container to be created after the root container (CON_ID 1)
5 Check all files of the CDB
a View the redo log files of the CDB
SQL> col MEMBER format A40 SQL> select GROUP#, CON_ID, MEMBER from v$logfile;
Trang 29Copyright © 2013, Oracle and/or its affiliates All rights reserved
GROUP# CON_ID MEMBER - - -
3 0 /u01/app/oracle/oradata/cdb1/redo03.log
2 0 /u01/app/oracle/oradata/cdb1/redo02.log
1 0 /u01/app/oracle/oradata/cdb1/redo01.log SQL>
b View the control files of the CDB
SQL> col NAME format A60 SQL> select NAME , CON_ID from v$controlfile;
NAME CON_ID - -
/u01/app/oracle/oradata/cdb1/control01.ctl 0 /u01/app/oracle/fast_recovery_area/cdb1/control02.ctl 0 SQL>
c View all data files of the CDB, including those of the root and all PDBs
SQL> col file_name format A50 SQL> col tablespace_name format A8 SQL> col file_id format 9999
SQL> col con_id format 999 SQL> select FILE_NAME, TABLESPACE_NAME, FILE_ID, con_id
2 from cdb_data_files order by con_id ;
FILE_NAME TABLESPA FILE_ID CON_ID
- -
/u01/app/oracle/oradata/cdb1/users01.dbf USERS
6 1 /u01/app/oracle/oradata/cdb1/undotbs01.dbf UNDOTBS1
4 1 /u01/app/oracle/oradata/cdb1/sysaux01.dbf SYSAUX
3 1 /u01/app/oracle/oradata/cdb1/system01.dbf SYSTEM
1 1 /u01/app/oracle/oradata/cdb1/pdbseed/system01.dbf SYSTEM
5 2 /u01/app/oracle/oradata/cdb1/pdbseed/sysaux01.dbf SYSAUX
7 2 /u01/app/oracle/oradata/cdb1/pdb1_1/system01.dbf SYSTEM
Trang 30/u01/app/oracle/oradata/cdb1/pdb1_1/sysaux01.dbf SYSAUX
9 3 /u01/app/oracle/oradata/cdb1/pdb1_1/SAMPLE_SCHEMA_ USERS
10 3 users01.dbf /u01/app/oracle/oradata/cdb1/pdb1_1/example01.dbf EXAMPLE
drwxr-xr-x 2 oracle oinstall 4096 Sep 5 10:54 pdb1_1 drwxr-x - 2 oracle oinstall 4096 Sep 5 10:37 pdbseed -rw-r - 1 oracle oinstall 52429312 Sep 6 23:38 redo01.log -rw-r - 1 oracle oinstall 52429312 Sep 6 20:01 redo02.log -rw-r - 1 oracle oinstall 52429312 Sep 6 22:23 redo03.log -rw-r - 1 oracle oinstall 849354752 Sep 6 23:35 sysaux01.dbf -rw-r - 1 oracle oinstall 828383232 Sep 6 23:35 system01.dbf -rw-r - 1 oracle oinstall 571482112 Sep 6 23:18 temp01.dbf -rw-r - 1 oracle oinstall 246423552 Sep 6 23:36
undotbs01.dbf -rw-r - 1 oracle oinstall 5251072 Sep 6 22:29 users01.dbf
SQL> !ls -l $ORACLE_BASE/oradata/cdb1/pdbseed
total 985064 -rw-r - 1 oracle oinstall 88088576 Sep 5 10:50 pdbseed_temp01.dbf
-rw-r - 1 oracle oinstall 671096832 Sep 5 10:50 sysaux01.dbf -rw-r - 1 oracle oinstall 262152192 Sep 5 10:50 system01.dbf SQL>
There are only the SYSTEM and SYSAUX data files and a temp file for the seed
PDB
d Still connected to the root, now use DBA_DATA_FILES view
SQL> col file_name format A42 SQL> select FILE_NAME, TABLESPACE_NAME, FILE_ID
Trang 31Copyright © 2013, Oracle and/or its affiliates All rights reserved
Notice that only the root data files are listed
SQL> col NAME format A12 SQL> select FILE#, ts.name, ts.ts#, ts.con_id
2 from v$datafile d, v$tablespace ts
SQL> col file_name format A47 SQL> select FILE_NAME, TABLESPACE_NAME, FILE_ID
2 from cdb_temp_files;
FILE_NAME TABLESPA FILE_ID
- - -
Trang 32/u01/app/oracle/oradata/cdb1/temp01.dbf TEMP
1 /u01/app/oracle/oradata/cdb1/pdbseed/pdbseed_temp01.dbf TEMP
2 /u01/app/oracle/oradata/cdb1/pdb1_1/pdb1_1_temp01.dbf TEMP
3 SQL>
6 List all users created
a Verify that the SYSTEM user is created
SQL> col username format A22 SQL> select username, common, con_id from cdb_users
2 where username ='SYSTEM';
USERNAME COM CON_ID - - - SYSTEM YES 1 SYSTEM YES 2 SYSTEM YES 3 SQL>
Notice that the user SYSTEM exists in all containers as a common user
b List all common users of the CDB
SQL> select distinct username from cdb_users
2 where common ='YES';
USERNAME - DVF
MDSYS XS$NULL SYSKM APEX_040100 DIP
SPATIAL_WFS_ADMIN_USR FLOWS_FILES
SYSBACKUP CTXSYS OUTLN SPATIAL_CSW_ADMIN_USR GSMUSER
OLAPSYS SYSTEM
Trang 33Copyright © 2013, Oracle and/or its affiliates All rights reserved
ORACLE_OCM DVSYS AUDSYS ORDSYS DBSNMP OJVMSYS GSMADMIN_INTERNAL MDDATA
APEX_PUBLIC_USER ORDPLUGINS
APPQOSSYS GSMCATUSER ORDDATA SYSDG XDB SYS WMSYS LBACSYS ANONYMOUS SI_INFORMTN_SCHEMA
35 rows selected
SQL>
c List all local users of the CDB
SQL> select distinct username, con_id from cdb_users
2 where common ='NO';
USERNAME CON_ID - - SCOTT 3
Trang 34d List local users in the root
SQL> select username, con_id from cdb_users
2 where common ='NO';
USERNAME CON_ID - - SCOTT 3
Trang 35Copyright © 2013, Oracle and/or its affiliates All rights reserved
7 List all roles and privileges of the CDB
a List all roles of the CDB
SQL> col role format A30 SQL> select role, common, con_id from cdb_roles;
ROLE COM CON_ID - - - CONNECT YES 1 RESOURCE YES 1 DBA YES 1 AUDIT_ADMIN YES 1 AUDIT_VIEWER YES 1 SELECT_CATALOG_ROLE YES 1 EXECUTE_CATALOG_ROLE YES 1 DELETE_CATALOG_ROLE YES 1 PROF_ADMIN YES 1 EXP_FULL_DATABASE YES 1 IMP_FULL_DATABASE YES 1 CDB_DBA YES 1
… DV_XSTREAM_ADMIN YES 2 DV_GOLDENGATE_REDO_ACCESS YES 2 DV_AUDIT_CLEANUP YES 2 DV_REALM_OWNER YES 2 PDB_DBA YES 2
… DV_AUDIT_CLEANUP YES 3 DV_REALM_RESOURCE YES 3 DV_REALM_OWNER YES 3 PDB_DBA YES 3
Trang 36b Check that the privileges are neither common nor local by nature
SQL> desc sys.system_privilege_map
Name Null? Type - - - PRIVILEGE NOT NULL NUMBER
NAME NOT NULL VARCHAR2(40) PROPERTY NOT NULL NUMBER
SQL> desc sys.table_privilege_map
Name Null? Type - - - PRIVILEGE NOT NULL NUMBER
NAME NOT NULL VARCHAR2(40) SQL>
Notice that there is no COMMON column
c Verify that the privilege, when granted, becomes a common or local privilege
SQL> desc CDB_SYS_PRIVS
Name Null? Type - - - GRANTEE VARCHAR2(128)
PRIVILEGE VARCHAR2(40) ADMIN_OPTION VARCHAR2(3)
OWNER VARCHAR2(128) TABLE_NAME VARCHAR2(128) GRANTOR VARCHAR2(128) PRIVILEGE VARCHAR2(40) GRANTABLE VARCHAR2(3) HIERARCHY VARCHAR2(3)
COMMON VARCHAR2(3)
TYPE VARCHAR2(24) CON_ID NUMBER
Trang 37Copyright © 2013, Oracle and/or its affiliates All rights reserved
d Notice that the role, though common or local depending on how the role was created is also, like privileges, either granted commonly or locally
SQL> col grantee format A10 SQL> col granted_role format A28 SQL> select grantee, granted_role, common, con_id
2 from cdb_role_privs
3 where grantee='SYSTEM';
GRANTEE GRANTED_ROLE COM CON_ID - - - - SYSTEM DBA YES 1 SYSTEM AQ_ADMINISTRATOR_ROLE YES 1 SYSTEM DBA YES 2 SYSTEM AQ_ADMINISTRATOR_ROLE YES 2 SYSTEM DBA YES 3 SYSTEM AQ_ADMINISTRATOR_ROLE YES 3
Trang 39Copyright © 2013, Oracle and/or its affiliates All rights reserved
Practices for Lesson 3:
Creating a Multitenant Container Database and Pluggable Databases
Trang 40Practices for Lesson 3