SlideShare a Scribd company logo
Pluggable Database tutorial Part 2
Osama Mustafa Page 1
In my Part 1 Tutorial for how to deal with Pluggable database 12c I mentioned how to use
pluggable database, How to create pluggable database, how to create table space, and how to
open/close pluggable database.
Please checks the Part (1) before continue reading this article here.
Welcome to Pluggable database Part 2
 Rename Pluggable Database
 Manage Pluggable database
 Drop Pluggable database
 Security In Pluggable database
SQL> select name, con_id from v$active_services order by 1;
NAME CON_ID
----------------------------- ----------
TEST 3
As you see in the above query, I already created pluggable database called test. and it's in Read
write Mode.
Rename Pluggable database
SQL> alter pluggable database TEST close immediate ;
Pluggable database altered.
SQL> alter pluggable database TEST open restricted ;
Pluggable database altered.
SQL> select name, open_mode from v$pdbs;
NAME OPEN_MODE
------------------------------ ----------
TEST READ WRITE
SQL> alter pluggable database TEST rename global_name to new ;
Pluggable database altered.
Pluggable Database tutorial Part 2
Osama Mustafa Page 2
SQL> select name, con_id from v$active_services order by 1;
NAME CON_ID
--------------------------------------- ----------
new 3
if you are not connected to pluggable database or set session container then you will receive error
message
ORA-65046: operation not allowed from outside a pluggable
SQL> alter pluggable database new close immediate;
Pluggable database altered.
SQL> alter pluggable database new open ;
Pluggable database altered.
Manage Pluggable Database
Back to root container using / as sysdba like below:
SQL> conn / as sysdba
Connected.
SQL> select name, con_id from v$active_services order by 1;
NAME CON_ID
--------------------------------------------------- ----------
SYS$BACKGROUND 1
SYS$USERS 1
db12c 1
db12cXDB 1
new 3
We Control which list for for tablespace & datafiles by using con_id.
 List tablespace in root container
Pluggable Database tutorial Part 2
Osama Mustafa Page 3
SQL> select tablespace_name, con_id from cdb_tablespaces where con_id=1;
TABLESPACE_NAME CON_ID
------------------------------ ----------
SYSTEM 1
SYSAUX 1
UNDOTBS1 1
TEMP 1
USERS 1
CDATA 1
 List Database In root Container
SQL> select file_name, con_id from cdb_data_files where con_id=1;
FILE_NAME CON_ID
--------------------------------------------------------------------- ----------
/u01/app/oracle/oradata/db12c/users01.dbf 1
/u01/app/oracle/oradata/db12c/undotbs01.dbf 1
/u01/app/oracle/oradata/db12c/sysaux01.dbf 1
/u01/app/oracle/oradata/db12c/system01.dbf 1
/u01/app/oracle/oradata/db12c/gls/test.dbf 1
 Temp Tablespace in root container
SQL> select file_name, con_id from cdb_temp_files where con_id=1;
FILE_NAME CON_ID
----------------------------------------------------------------------------- ----------
/u01/app/oracle/oradata/db12c/temp01.dbf 1
 Create Tablespace ( already mentioned in Part (1))
SQL> create tablespace test datafile '/u01/app/oracle/oradata/db12c/gls/test03.dbf' size 20M;
Tablespace created.
Pluggable Database tutorial Part 2
Osama Mustafa Page 4
SQL> select tablespace_name, con_id from cdb_tablespaces order by con_id;
TABLESPACE_NAME CON_ID
------------------------------ ----------
SYSTEM 1
TEST 1
CDATA 1
SYSAUX 1
TEMP 1
UNDOTBS1 1
USERS 1
SYSAUX 2
TEMP 2
SYSTEM 2
TEMP 3
SYSAUX 3
PDB_TEST 3
SYSTEM 3
14 rows selected.
 Create temp tablespace
SQL> create temporary tablespace temp_test tempfile
'/u01/app/oracle/oradata/db12c/gls/temp_test.dbf' size 20M ;
Tablespace created.
SQL> select file_name, con_id from cdb_temp_files where con_id=1;
FILE_NAME CON_ID
--------------------------------------------------------------------------- ----------
/u01/app/oracle/oradata/db12c/temp01.dbf 1
/u01/app/oracle/oradata/db12c/gls/temp_test.dbf 1
The Same Steps in root container for create tablespace and temp tablespace for pluggable
database.
Pluggable Database tutorial Part 2
Osama Mustafa Page 5
Security In Pluggable Database
In This Section we will discuss how to manage Users, roles and privileges.
before Demonstration you need to know what is the difference between two users type :
 Common: when you create this kind of users in root it's automatically replicated
in all Pluggable database.
 Local: this kind of users only created on pluggable database that you are
connected to it now. and dose not effect on others pluggable database.
To Create Common Users you need to be connected to root container.
SQL> conn / as sysdba
Connected.
SQL> create user c##osama identified by osama ;
User created.
SQL> select username, common, con_id from cdb_users where username like 'C##%';
USERNAME COM CON_ID
------------------------------------ --- ----------
C##TEST YES 1
C##OSAMA YES 1
C##TEST YES 3
C##OSAMA YES 3
SQL> grant create session to c##osama ;
Grant succeeded.
SQL> conn c##osama/osama@test12c:1521/db12c ;
Connected.
Pluggable Database tutorial Part 2
Osama Mustafa Page 6
Let's connect to pluggable database :
The user i will created it here will not appear in root container.
SQL> conn sys/sys@test12c:1521/new as sysdba
Connected.
SQL> create user test identified by test ;
User created.
SQL> grant create session to test ;
Grant succeeded.
SQL> select username, common, con_id from cdb_users where username ='TEST';
USERNAME COM CON_ID
------------------ ----------
TEST NO 3
SQL> conn test/test@test12c:1521/new ;
Connected.
Same rules and conditions applied on Roles if you created in Root Container it will be replicated
to pluggable database, on other hand if you created in Pluggable database it will be local without
effecting Container.
Let's connect to Root Container
SQL> conn / as sysdba
Connected.
SQL> create role c##root_role ;
Role created.
Pluggable Database tutorial Part 2
Osama Mustafa Page 7
SQL> select role, common, con_id from cdb_roles where role='C##ROOT_ROLE';
ROLE COM CON_ID
--------------------- --- ----------
C##ROOT_ROLE YES 1
C##ROOT_ROLE YES 3
SQL> conn sys/sys@test12c:1521/new as sysdba
Connected.
SQL> create role test2;
Role created.
SQL> select role, common, con_id from cdb_roles where role='TEST2';
ROLE COM CON_ID
---------------- --- ----------
TEST2 NO 3
SQL> create role hr container=all ;
create role hr container=all
*
ERROR at line 1:
ORA-65050: Common DDLs only allowed in CDB$ROOT
SQL> create user hr identified by hr container=all ;
create user hr identified by hr container=all
*
ERROR at line 1:
ORA-65050: Common DDLs only allowed in CDB$ROOT
---> you cannot create a common role inside a PDB.
Pluggable Database tutorial Part 2
Osama Mustafa Page 8
Check user privileges:
SQL> select grantee, privilege, common, con_id from cdb_sys_privs
where privilege='CREATE SESSION' and grantee='TEST';
GRANTEE PRIVILEGE COM CON_ID
-------------- ---------------------------------------
TEST CREATE SESSION NO 3
Drop Pluggable Database
SQL > drop pluggable database new including datafiles;
Pluugable database dropped.

More Related Content

PDF
Pluggable database 3
PDF
Pluggable database tutorial
PDF
Enable oracle database vault
PDF
Upgrade Oracle Database to 12c
PDF
Oracle to MySQL DatabaseLink
DOCX
Upgrade EBS DB from 11g to 12c.
DOCX
Physical_Standby_Database_R12.2.4
PDF
Deploy agent in em12c
Pluggable database 3
Pluggable database tutorial
Enable oracle database vault
Upgrade Oracle Database to 12c
Oracle to MySQL DatabaseLink
Upgrade EBS DB from 11g to 12c.
Physical_Standby_Database_R12.2.4
Deploy agent in em12c

What's hot (20)

DOCX
Upgrading mysql version 5.5.30 to 5.6.10
PDF
Rac&asm
PDF
Basic - Oracle Edition Based Redefinition Presentation
 
DOC
Schema replication using oracle golden gate 12c
PDF
Oracle business intelligence enterprise edition 11g
DOCX
Mater,slave on mysql
PDF
FIXING BLOCK CORRUPTION (RMAN) on 11G
 
PDF
Refresh development from productions
PDF
Are You Ready for 12c? Data Migration and Upgrade Best Practices
DOCX
Oracle 12cR2 RAC Database Software Installation and Create Database
PDF
Database decommission process
TXT
oracle dba
PDF
12c on RHEL7
PPTX
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
TXT
Oracle ORA Errors
PPTX
Database administration commands
DOC
Oracle data guard configuration in 12c
PDF
Oracle Database 11g Product Family
 
PDF
Steps to Create odbc connection linux
DOCX
Inno db datafiles backup and retore
Upgrading mysql version 5.5.30 to 5.6.10
Rac&asm
Basic - Oracle Edition Based Redefinition Presentation
 
Schema replication using oracle golden gate 12c
Oracle business intelligence enterprise edition 11g
Mater,slave on mysql
FIXING BLOCK CORRUPTION (RMAN) on 11G
 
Refresh development from productions
Are You Ready for 12c? Data Migration and Upgrade Best Practices
Oracle 12cR2 RAC Database Software Installation and Create Database
Database decommission process
oracle dba
12c on RHEL7
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle ORA Errors
Database administration commands
Oracle data guard configuration in 12c
Oracle Database 11g Product Family
 
Steps to Create odbc connection linux
Inno db datafiles backup and retore
Ad

Viewers also liked (17)

PDF
25605 tutorial migrasi database dari my sql ke oracle ( kelompok 9 )
PDF
competitive pricing in business market
PDF
Database reports generation(database)
PDF
Oracle tutorial
PPTX
firm performance presentation(INDUSTRAT)
PDF
Migrasi database mysql ke oracle-sql developer
PPTX
Oracle Database View
PDF
Oracle smart flash cache
PDF
Exadata Smart Scan - What is so smart about it?
PDF
Tutorial Migrasi Database dari Microsoft SQL Server ke Oracle Database
PDF
AWR & ASH Analysis
DOC
Oracl DBA lab manual
PDF
Oracle sql tutorial
PPTX
Oracle Tablespace - Basic
PPT
Oracle Database Trigger
PPTX
Migrating to Oracle Database 12c: 300 DBs in 300 days.
PDF
Add target manually em12c
25605 tutorial migrasi database dari my sql ke oracle ( kelompok 9 )
competitive pricing in business market
Database reports generation(database)
Oracle tutorial
firm performance presentation(INDUSTRAT)
Migrasi database mysql ke oracle-sql developer
Oracle Database View
Oracle smart flash cache
Exadata Smart Scan - What is so smart about it?
Tutorial Migrasi Database dari Microsoft SQL Server ke Oracle Database
AWR & ASH Analysis
Oracl DBA lab manual
Oracle sql tutorial
Oracle Tablespace - Basic
Oracle Database Trigger
Migrating to Oracle Database 12c: 300 DBs in 300 days.
Add target manually em12c
Ad

Similar to Pluggable database tutorial 2 (20)

PPTX
Oracle 12c - Multitenant Feature
PDF
Cdb part i
PDF
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
PDF
Exploring Oracle Database 12c Multitenant best practices for your Cloud
PDF
How to create a pluggable database by cloning an existing local pdb
PPT
173955573244324324324424322adsadsaasd.ppt
PPTX
Simplify Consolidation with Oracle Pluggable Databases
PPTX
Using oracle12c pluggable databases to archive
PPTX
Database 12c
PDF
Oracle 12c PDB insights
PDF
PDF
154090896 installation-of-oracle-database-12c
PDF
Security Multitenant
PPTX
Oracle Database 12.1.0.2 New Features
PPTX
Presentation day5 oracle12c
PPTX
Oracle Database 12.1.0.2 New Features
PPTX
Presentation day4 oracle12c
PDF
One PDB to go, please!
PDF
2017 10-oow-fma-application-containers-v01-final
PPTX
OEM12c, DB12c and You! - RMOUG TD2014 Edition
Oracle 12c - Multitenant Feature
Cdb part i
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Exploring Oracle Database 12c Multitenant best practices for your Cloud
How to create a pluggable database by cloning an existing local pdb
173955573244324324324424322adsadsaasd.ppt
Simplify Consolidation with Oracle Pluggable Databases
Using oracle12c pluggable databases to archive
Database 12c
Oracle 12c PDB insights
154090896 installation-of-oracle-database-12c
Security Multitenant
Oracle Database 12.1.0.2 New Features
Presentation day5 oracle12c
Oracle Database 12.1.0.2 New Features
Presentation day4 oracle12c
One PDB to go, please!
2017 10-oow-fma-application-containers-v01-final
OEM12c, DB12c and You! - RMOUG TD2014 Edition

More from Osama Mustafa (20)

PDF
Case study for software architect
PPTX
DevOps for database
PPTX
Does cloud mean the end of the dba
PDF
Using git hub for your code
PDF
DevOps Project
PDF
Java business service
PDF
Steps creating data_integration_services
PDF
Build, Deploy and Run Node Js Application on Azure using Docker
PDF
Oracle api gateway installation as cluster and single node
PDF
Helping implementer dealing with famous siebel based system messages and er...
PPTX
Weblogic and docker
PPTX
Weblogic 101 for dba
PDF
Ebs clone r12.2.4
PDF
Oracle obia 11.1.1.10.1 installation
PDF
Oracle Enterprise manager 13c Installation
PDF
Erp installation r12.2
PDF
OBIA Installation
PPTX
Eouc 12 on 12c osama mustafa
PDF
Install oracle siebel on windows 2008 r2
PDF
Oracle autovue
Case study for software architect
DevOps for database
Does cloud mean the end of the dba
Using git hub for your code
DevOps Project
Java business service
Steps creating data_integration_services
Build, Deploy and Run Node Js Application on Azure using Docker
Oracle api gateway installation as cluster and single node
Helping implementer dealing with famous siebel based system messages and er...
Weblogic and docker
Weblogic 101 for dba
Ebs clone r12.2.4
Oracle obia 11.1.1.10.1 installation
Oracle Enterprise manager 13c Installation
Erp installation r12.2
OBIA Installation
Eouc 12 on 12c osama mustafa
Install oracle siebel on windows 2008 r2
Oracle autovue

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Approach and Philosophy of On baking technology
PDF
cuic standard and advanced reporting.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Electronic commerce courselecture one. Pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
KodekX | Application Modernization Development
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
Machine learning based COVID-19 study performance prediction
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Approach and Philosophy of On baking technology
cuic standard and advanced reporting.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Spectral efficient network and resource selection model in 5G networks
MYSQL Presentation for SQL database connectivity
Electronic commerce courselecture one. Pdf
Review of recent advances in non-invasive hemoglobin estimation
Dropbox Q2 2025 Financial Results & Investor Presentation
The AUB Centre for AI in Media Proposal.docx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Per capita expenditure prediction using model stacking based on satellite ima...
KodekX | Application Modernization Development
20250228 LYD VKU AI Blended-Learning.pptx

Pluggable database tutorial 2

  • 1. Pluggable Database tutorial Part 2 Osama Mustafa Page 1 In my Part 1 Tutorial for how to deal with Pluggable database 12c I mentioned how to use pluggable database, How to create pluggable database, how to create table space, and how to open/close pluggable database. Please checks the Part (1) before continue reading this article here. Welcome to Pluggable database Part 2  Rename Pluggable Database  Manage Pluggable database  Drop Pluggable database  Security In Pluggable database SQL> select name, con_id from v$active_services order by 1; NAME CON_ID ----------------------------- ---------- TEST 3 As you see in the above query, I already created pluggable database called test. and it's in Read write Mode. Rename Pluggable database SQL> alter pluggable database TEST close immediate ; Pluggable database altered. SQL> alter pluggable database TEST open restricted ; Pluggable database altered. SQL> select name, open_mode from v$pdbs; NAME OPEN_MODE ------------------------------ ---------- TEST READ WRITE SQL> alter pluggable database TEST rename global_name to new ; Pluggable database altered.
  • 2. Pluggable Database tutorial Part 2 Osama Mustafa Page 2 SQL> select name, con_id from v$active_services order by 1; NAME CON_ID --------------------------------------- ---------- new 3 if you are not connected to pluggable database or set session container then you will receive error message ORA-65046: operation not allowed from outside a pluggable SQL> alter pluggable database new close immediate; Pluggable database altered. SQL> alter pluggable database new open ; Pluggable database altered. Manage Pluggable Database Back to root container using / as sysdba like below: SQL> conn / as sysdba Connected. SQL> select name, con_id from v$active_services order by 1; NAME CON_ID --------------------------------------------------- ---------- SYS$BACKGROUND 1 SYS$USERS 1 db12c 1 db12cXDB 1 new 3 We Control which list for for tablespace & datafiles by using con_id.  List tablespace in root container
  • 3. Pluggable Database tutorial Part 2 Osama Mustafa Page 3 SQL> select tablespace_name, con_id from cdb_tablespaces where con_id=1; TABLESPACE_NAME CON_ID ------------------------------ ---------- SYSTEM 1 SYSAUX 1 UNDOTBS1 1 TEMP 1 USERS 1 CDATA 1  List Database In root Container SQL> select file_name, con_id from cdb_data_files where con_id=1; FILE_NAME CON_ID --------------------------------------------------------------------- ---------- /u01/app/oracle/oradata/db12c/users01.dbf 1 /u01/app/oracle/oradata/db12c/undotbs01.dbf 1 /u01/app/oracle/oradata/db12c/sysaux01.dbf 1 /u01/app/oracle/oradata/db12c/system01.dbf 1 /u01/app/oracle/oradata/db12c/gls/test.dbf 1  Temp Tablespace in root container SQL> select file_name, con_id from cdb_temp_files where con_id=1; FILE_NAME CON_ID ----------------------------------------------------------------------------- ---------- /u01/app/oracle/oradata/db12c/temp01.dbf 1  Create Tablespace ( already mentioned in Part (1)) SQL> create tablespace test datafile '/u01/app/oracle/oradata/db12c/gls/test03.dbf' size 20M; Tablespace created.
  • 4. Pluggable Database tutorial Part 2 Osama Mustafa Page 4 SQL> select tablespace_name, con_id from cdb_tablespaces order by con_id; TABLESPACE_NAME CON_ID ------------------------------ ---------- SYSTEM 1 TEST 1 CDATA 1 SYSAUX 1 TEMP 1 UNDOTBS1 1 USERS 1 SYSAUX 2 TEMP 2 SYSTEM 2 TEMP 3 SYSAUX 3 PDB_TEST 3 SYSTEM 3 14 rows selected.  Create temp tablespace SQL> create temporary tablespace temp_test tempfile '/u01/app/oracle/oradata/db12c/gls/temp_test.dbf' size 20M ; Tablespace created. SQL> select file_name, con_id from cdb_temp_files where con_id=1; FILE_NAME CON_ID --------------------------------------------------------------------------- ---------- /u01/app/oracle/oradata/db12c/temp01.dbf 1 /u01/app/oracle/oradata/db12c/gls/temp_test.dbf 1 The Same Steps in root container for create tablespace and temp tablespace for pluggable database.
  • 5. Pluggable Database tutorial Part 2 Osama Mustafa Page 5 Security In Pluggable Database In This Section we will discuss how to manage Users, roles and privileges. before Demonstration you need to know what is the difference between two users type :  Common: when you create this kind of users in root it's automatically replicated in all Pluggable database.  Local: this kind of users only created on pluggable database that you are connected to it now. and dose not effect on others pluggable database. To Create Common Users you need to be connected to root container. SQL> conn / as sysdba Connected. SQL> create user c##osama identified by osama ; User created. SQL> select username, common, con_id from cdb_users where username like 'C##%'; USERNAME COM CON_ID ------------------------------------ --- ---------- C##TEST YES 1 C##OSAMA YES 1 C##TEST YES 3 C##OSAMA YES 3 SQL> grant create session to c##osama ; Grant succeeded. SQL> conn c##osama/osama@test12c:1521/db12c ; Connected.
  • 6. Pluggable Database tutorial Part 2 Osama Mustafa Page 6 Let's connect to pluggable database : The user i will created it here will not appear in root container. SQL> conn sys/sys@test12c:1521/new as sysdba Connected. SQL> create user test identified by test ; User created. SQL> grant create session to test ; Grant succeeded. SQL> select username, common, con_id from cdb_users where username ='TEST'; USERNAME COM CON_ID ------------------ ---------- TEST NO 3 SQL> conn test/test@test12c:1521/new ; Connected. Same rules and conditions applied on Roles if you created in Root Container it will be replicated to pluggable database, on other hand if you created in Pluggable database it will be local without effecting Container. Let's connect to Root Container SQL> conn / as sysdba Connected. SQL> create role c##root_role ; Role created.
  • 7. Pluggable Database tutorial Part 2 Osama Mustafa Page 7 SQL> select role, common, con_id from cdb_roles where role='C##ROOT_ROLE'; ROLE COM CON_ID --------------------- --- ---------- C##ROOT_ROLE YES 1 C##ROOT_ROLE YES 3 SQL> conn sys/sys@test12c:1521/new as sysdba Connected. SQL> create role test2; Role created. SQL> select role, common, con_id from cdb_roles where role='TEST2'; ROLE COM CON_ID ---------------- --- ---------- TEST2 NO 3 SQL> create role hr container=all ; create role hr container=all * ERROR at line 1: ORA-65050: Common DDLs only allowed in CDB$ROOT SQL> create user hr identified by hr container=all ; create user hr identified by hr container=all * ERROR at line 1: ORA-65050: Common DDLs only allowed in CDB$ROOT ---> you cannot create a common role inside a PDB.
  • 8. Pluggable Database tutorial Part 2 Osama Mustafa Page 8 Check user privileges: SQL> select grantee, privilege, common, con_id from cdb_sys_privs where privilege='CREATE SESSION' and grantee='TEST'; GRANTEE PRIVILEGE COM CON_ID -------------- --------------------------------------- TEST CREATE SESSION NO 3 Drop Pluggable Database SQL > drop pluggable database new including datafiles; Pluugable database dropped.