Monday, August 31, 2015

Oracle 12c Drop PDBs


https://www.youtube.com/watch?v=PaNUTYBK8EM&index=5&list=PLFIuxLy_v_CVZIDNyLYsO49TGZxcXANil

run query to check list of PDB's

SELECT b.con_id, a.pdb_name, a.status,b.open_mode
from dba_pdbs a, v$pdbs b
where a.pdb_name=b.name
order by b.con_id;

SYNTAX FOR DROPPING PLUGGABLE DATABASES
=======================================
drop pluggable database pdb4 (KEEP/INCLUDING) datafiles
drop pluggable database pdb4 INCLUDING DATAFILES;

NOTE YOU CANNOT  DROP READ WRITE DATABASE


PDB MUST BE CLOSED BEFORE DROPPING IT

SQL>alter pluggable database pdb4 close immediate;
SQL>drop pluggable database pdb4 INCLUDING DATAFILES;

run query to check list of PDB's

SELECT b.con_id, a.pdb_name, a.status,b.open_mode
from dba_pdbs a, v$pdbs b
where a.pdb_name=b.name
order by b.con_id;

Oracle 12c CREATING PLUGABLE DATABASE USING CLONE OPTION

https://www.youtube.com/watch?v=pVybw0xVv98&list=PLFIuxLy_v_CVZIDNyLYsO49TGZxcXANil&index=6


run query to check list of PDB's

SELECT b.con_id, a.pdb_name, a.status,b.open_mode
from dba_pdbs a, v$pdbs b
where a.pdb_name=b.name
order by b.con_id;


FROM THE LIST YOU CAN SELECT ONE OF THE DATABASE WHICH IS READ ONLY MODE
SQL>CREATE PLUGGABLE DATABASE pdb_sales_dev from pdb_sales;

run query to check list of PDB's

SELECT b.con_id, a.pdb_name, a.status,b.open_mode
from dba_pdbs a, v$pdbs b
where a.pdb_name=b.name
order by b.con_id;


query con_id of newly created by clone
SQL>SELECT NAME FROM V$DATAFILE WHERE CON_ID=5;
SQL>SELECT NAME FROM V$TEMPFILE WHERE CON_ID=5;


CREATE FOLDERS FOR DATAFILE AND TEMPFILES

EXIT
mkdir -p /u02/app/oracle/oradata/syed/pdb_hr_dev/DATAFILE
mkdir -p /u02/app/oracle/oradata/syed/pdb_hr_dev/TEMPFILE
sqlplus / as sysdba



SELECT b.con_id, a.pdb_name, a.status,b.open_mode
from dba_pdbs a, v$pdbs b
where a.pdb_name=b.name
order by b.con_id;

QUERY FOR ANY EXISTING DATABASE

SQL>select name from v$datafile where con_id=3;
SQL>CREATE PLUGGABLE DATABASE pdb_sales_dev from pdb_sales;
STORAGE (MAXSIZE 50G MAX_SHARED_TEMP_SIZE 50 G)
FILE_NAME_CONVERT=('SOURCE DBFILE LOCATION','/u02/app/oracle/oradata/syed/pdb_hr_dev/')
PATH_PREFIX='/u02/app/oracle/oradata/syed/pdb_hr_dev/')
;


SELECT b.con_id, a.pdb_name, a.status,b.open_mode
from dba_pdbs a, v$pdbs b
where a.pdb_name=b.name
order by b.con_id;



query con_id of newly created by clone
SQL>SELECT NAME FROM V$DATAFILE WHERE CON_ID=5;
SQL>SELECT NAME FROM V$TEMPFILE WHERE CON_ID=5;


OPEN AND CLOSE PDBS'S

https://www.youtube.com/watch?v=eh_RLA90SUo&list=PLFIuxLy_v_CVZIDNyLYsO49TGZxcXANil&index=4


ALTER PLUGGABLE DATABASE
Modifying the Settings of a PDB: Example
ALTER PLUGGABLE DATABASE pdb2  STORAGE (MAXSIZE 500M);

Taking the Data Files of a PDB Offline: Example
ALTER PLUGGABLE DATABASE pdb3 DATAFILE ALL OFFLINE;


ALTER PLUGGABLE DATABASE pdb4  OPEN READ ONLY;

run query to check list of PDB's

SELECT b.con_id, a.pdb_name, a.status,b.open_mode
from dba_pdbs a, v$pdbs b
where a.pdb_name=b.name
order by b.con_id;
 FORCE;
ALTER PLUGGABLE DATABASE pdb4  CLOSE;

ALTER PLUGGABLE DATABASE pdb4 OPEN READ ONLY RESTRICTED;


ALTER PLUGGABLE DATABASE pdb6
  CLOSE RELOCATE TO 'ORCLDB_3';In an Oracle Real Application Clusters environment, the following statement closes PDB pdb6 in the current instance and instructs the database to reopen pdb6 in instance ORCLDB_3:


run query to check list of PDB's

SELECT b.con_id, a.pdb_name, a.status,b.open_mode
from dba_pdbs a, v$pdbs b
where a.pdb_name=b.name
order by b.con_id;

NOTE AFTER CREATION YOU HAVE TO OPEN IN READ WRITE MODE NOT READ ONLY MODE
SQL> ALTER PLUGGABLE DATABASE pdb4 OPEN READ WRITE;
SQL> ALTER PLUGGABLE DATABASE pdb4,pdb3 CLOSE IMMEDIATE;
SQL> ALTER PLUGGABLE DATABASE pdb4,pdb3 OPEN READ WRITE;
SQL> ALTER PLUGGABLE DATABASE ALL CLOSE IMMEDIATE;
SQL> ALTER PLUGGABLE DATABASE ALL EXCEPT pdb3 OPEN READ WRITE;
SQL> ALTER PLUGGABLE DATABASE ALL EXCEPT pdb3 CLOSE IMMEDIATE;
SQL> ALTER PLUGGABLE DATABASE pdb4 open resetlogs


YOU CANNOT OPEN OR CLOSE SEED DATABASE;

Oracle 12c Create PDB From Seed



https://www.youtube.com/watch?v=Z57FrM1hn8c

sqlplus / as sysdba
SQL>select intance_name,version, status from v$instance;
SQL>select name,cdb from v$database;
cdb should be yes

SELECT b.con_id, a.pdb_name, a.status,b.open_mode
from dba_pdbs a, v$pdbs b
where a.pdb_name=b.name


can create plugable database using 3 methods
1)create PDB from PDB$seed
2)create PDB from cloning an existing pdb
3)create PDB by plugging and unplugged pdb

http://docs.oracle.com/database/121/SQLRF/statements_6010.htm#CCHBFIDF
1)create PDB from PDB$seed

Syntax

create_pluggable_database::=

Description of create_pluggable_database.gif follows
Description of the illustration create_pluggable_database.gif


SQL>create pluggable database pdb_hr
admin user pdb_hr_admin  identified by india123;

run query to check list of PDB's

SELECT b.con_id, a.pdb_name, a.status,b.open_mode
from dba_pdbs a, v$pdbs b
where a.pdb_name=b.name

it will show mounted

Example 2

creating PDB with more details storage option is ASM

SQL>create pluggable database pdb_sales
admin user pdb_sales_admin  identified by india123
default tablespace  pdb_sales_users_tbs
storage (maxsize 100g max_shared_temp_size 100g)
;

run query to check list of PDB's

SELECT b.con_id, a.pdb_name, a.status,b.open_mode
from dba_pdbs a, v$pdbs b
where a.pdb_name=b.name

it will show 2nd one mounted too mounted



exit
I will create 2 folders temp and data file systtem for another pdb database
mkdir -p /u02/app/oracle/oradata/syed/pbd_mktg/DATAFILE
mkdir -p /u02/app/oracle/oradata/syed/pbd_mktg/TEMPFILE

SQLPLUS / AS SYSDBA
run query to check list of PDB's

SELECT b.con_id, a.pdb_name, a.status,b.open_mode
from dba_pdbs a, v$pdbs b
where a.pdb_name=b.name

CHECK DATAFILE LOCATION FOR PDB$SEED
SQL>select name from v$datafile where con_id=2;  ( where 2 is is seed conid)
it will give you path

copy the path
now create  5TH ONE
CREATE



SQL>create pluggable database pdb_mktg
admin user pdb_mktg_admin  identified by india123
default tablespace  pdb_mktg_users_tbs
DATAFILE '/u02/app/oracle/oradata/syed/pbd_mktg/DATAFILE/pdb_mktg_users_tbs_001.dat'
size 1g
FILE_NAME_CONVERT=('+DATA/select name from v$datafile where con_id=2','/u02/app/oracle/oradata/syed/pbd_mktg/')
STORAGE (MAXSIZE 10G MAX_SHARED_TEMP_SIZE 10G)
PATH_PREFIX='/u02/app/oracle/oradata/syed/pbd_mktg/'


SQL>SELECT NAME FROM V$DATAFILE WHERE CON_ID=3;
SQL>SELECT NAME FROM V$TEMPFILE WHERE CON_ID=3;
SQL>SELECT NAME FROM V$DATAFILE WHERE CON_ID=5;


;

SELECT b.con_id, a.pdb_name, a.status,b.open_mode
from dba_pdbs a, v$pdbs b
where a.pdb_name=b.name








oracle 12c - Create and Configure a Container Database (CDB) and PDB USING DBCA





su - oracle
echo $ORACLE_HOME
/u01/app/oracle/product/12.1.0/dbhome_1/
echo $ORACLE_BASE
/u01/app/oracle
$dbca
create database
click advance mode
next
general purpose
nextt
global databse name:cdb1
sid cdb1
PDB name ==pdb
next
configure enterprize management database express
next
Database credentials
use same adminstrator password  for all accounts
Networkconfiguration
select
next
 uncheck and nexr
next
database option
check sample schemas
next
Installaation parameters
precheck
and
finish
========================================================================
https://www.youtube.com/watch?v=-zMNZrg_BqU&list=PLFIuxLy_v_CVZIDNyLYsO49TGZxcXANil


Oracle 12c DBCA Create CDB PDBs
install gridinfrastructue
and dbms software
cat /etc/oratab
ps -ef |grep -i smon
cd /u01/app/oracle/product/12.1.0/dbHome_1/bin/dbca &

1)create database
2)DATABASE TEMPLATE: custom database option
3)DATABASE IDENTIFICATION:   Global database Name :cdb1
                                              SID :cdb1
                              create  container database
                                 Number of PDB     :2

                                 PDB name prefix  :pdb
                    Next
4)MANAGEMENT OPTIONS                              :  configure enterprize Manager database express
5)DATABASE CREDENTIALS                           : Use the same administrative password for all accounts
6)NETWORK CONFIGURATION                          : LISTENER
7) STORAGE LOCATION                               :ASM
        USE COMMON LOCATION                       :+DATA
             USE OMF
               FASTRECOVERY AREA                  :+FRA
                10 CBYTES
                  ENABLE ARCHIVELOG
8)DATABASE OPTION                                   :NEXT
9)DATABASE VAULT                               : UNCHECK K CONFIGURE DATABASE VAULT
                                                  UNCHECK LABEL SECURITY
10)INTITIALIZATION PARAMETER                   : TYPICAL SETTING
                                                : ENABLE AUTOMATIC MEMORY MANAGENT
11)CREATION OPTION                         :GENERATE DATABASE CREATION SCRIPTS
                                            :CREATE DATABASE
NEXT
FINISH


LOOOK AT ORATAB FILE
cdb1:/u01/app/oracle/product/12.1.0/dbhome_1:N
ps -ef|grep -i smon


. oraenv
cdb1
lsnrctl start
sqlplus / as sysdba
SQL>select instance_name ,version , status from v$instance;
SQL>select dbid,name,cdb,con_id, con_dbid from v$database;
SQL>select pdb_id,dbid, pdb_name,status from cdb_pdbs order pdb_id;


============================================================================================




Thursday, September 3, 2015

Installing Oracle Database 12c as Container Database with three Pluggable DatabasesInstalling Oracle Database 12c as Container Database with three Pluggable Databases

Installing Oracle Database 12c as Container Database with three Pluggable Databases

 
Here is a video recorded during the creation of the first database. Go on if you want to see all the screenshots.

So we have already installed the software of the Oracle Database 12c release 1 (have a look at this post) and now we want to create a database using dbca.
So let's run dbca from the oracle user.
  1. [oracle@vsi08devpom ~]$ dbca &  


Select the operation you want to perform using dbca. Because I've already created an Oracle Database all the options are available. Anyway I want to create another database so I'm going to select Create Database.
During the Creation Mode screen you have two options:
1. you can create a database with default configuration. It's possible to create it as Container Database and create also one Pluggable Database.


I'm not going to click the finish button right now. I want to use the second option to create a database.

2. So choose Advanced Mode in which you configure your own database structure. This option enables you to perform more complex installations, such as creating individual passwords for different accounts, creating specific types of starter databases (for example, for transaction processing or data warehouse systems), using different language groups, specifying email notifications, and so on.






During the Advanced Mode screens you can choose to create the database as Container Database.
Select the Create as Container database option to create the database as a multitenant container database (CDB) that can support one pluggable database (PDB). If you want Oracle Universal Installer to create a PDB when it creates the CDB, specify the PDB name in the Pluggable Database Name field. The PDB name must be unique. If you need to create more than one PDB you have to provide a PDB Name Prefix.

The next Advanced Mode screen asks you how you want to manage your database: configuring the EM Database Express or registering it with EM Cloud Control.


The next screen asks you to specify passwords for SYS, SYSTEM and PDBADMIN or use the same password for all accounts.


The next screen asks you to select a listener or create a new one.

The next screen asks you to specify the storage locations for database files (storage type: File System or Automatic Storage Management) and for recovery related files (you can specify a Fast Recovery Area and enable archiving)


The next screen shows you the several database components you are going to configure like Oracle Database Vault or Label Security.
The next screen asks you to configure Database Vault and Label Security (I didn't select them during this installation).


The next screen let you specify settings about memory, default database block size and the maximum number of operating system user processes simultaneously connected to the database, character sets and the connection mode (dedicated server mode or shared server mode).Select the Enable Automatic Memory Management option to allow the database to automatically distribute memory between SGA and PGA. If you do not select this option, then the SGA and PGA must be sized manually.

The next screen asks you to select the Creation Options for the database (create, save as database template, generate database creation scripts).
The pre requisite checks are all satisfied.
Creation of the database configuration summary.
Database configuration summary created. So click finish button to begin the installation process.
 The database creation is in progress... still 36%.
 The database is finally created as well as the EM Database Express. In my case I was running another EM Database Express so the next available port was used (5501 instead of the "already in use" 5500). If you want to change the port number of your EM Database Express have a look at this post.

 Some screenshots from the EM Database Express.

























overview of Container Databases (CDB) and Pluggable Databases (PDB)

Overview

The multitenant option represents one of the biggest architectural changes in the history of the Oracle database. The option introduced the concepts of the Container Database (CDB) and Pluggable Database (PDB).
  • Container Database (CDB) : On the surface this seems very similar to a conventional Oracle database, as it contains most of the working parts you will be already familiar with (controlfiles, datafiles, undo, tempfiles, redo logs etc.). It also houses the data dictionary for those objects that are owned by the root container and those that are visible to all PDBs.
  • Pluggable Database (PDB) : Since the CDB contains most of the working parts for the database, the PDB only needs to contain information specific to itself. It does not need to worry about controlfiles, redo logs and undo etc. Instead it is just made up of datafiles and tempfiles to handle it's own objects. This includes it's own data dictionary, containing information about only those objects that are specific to the PDB.

Views

The introduction of the multitenant option brings with it an extra layer of data dictionary views, allowing reporting across the root container and the pluggable databases (PDBs). Ignoring editions for the moment, prior releases had the following hierarchy.

DBA_ : All objects in the database.
|
--ALL_ : Objects accessible by the current user, including those owned by the current user.
  |
  --USER_ : Objects owned by the current user.

With Oracle 12c, an extra layer is added to the hierarchy.

CDB_ : All objects in all containers (root and all PDBs).
|
--DBA_ : All objects in the current container (root or PDB).
  |
  --ALL_ : Objects accessible by the current user in the current container (root or PDB), including those owned by the current user.
    |
    --USER_ : Objects owned by the current user in the current container (root or PDB).

Multitenant : Manage Users and Privileges For Container Databases (CDB) and Pluggable Databases (PDB) in Oracle

Multitenant : Manage Users and Privileges For Container Databases (CDB) and Pluggable Databases (PDB) in Oracle Database 12c Release 1 (12.1)
The multitenant option introduced in Oracle Database 12c allows a single container database (CDB) to host multiple separate pluggable databases (PDB). This article shows how to manage users and privileges for container databases (CDB) and pluggable databases (PDB).

Introduction
Create Common Users
Create Local Users

Create Common Roles
Create Local Roles

Granting Roles and Privileges to Common and Local Users
Introduction

When connected to a multitenant database the management of users and privileges is a little different to traditional Oracle environments. In multitenant environments there are two types of user.

Common User : The user is present in all containers (root and all PDBs).

Local User : The user is only present in a specific PDB. The same username can be present in multiple PDBs, but they are unrelated.

Likewise, there are two types of roles.

Common Role : The role is present in all containers (root and all PDBs).

Local Role : The role is only present in a specific PDB. The same role name can be used in multiple PDBs, but they are unrelated.

Some DDL statements have a CONTAINER clause added to allow them to be directed to the current container or all containers. Its usage will be demonstrated in the sections below.

Create Common Users

When creating a common user the following requirements must all be met.

1 )You must be connected to a common user with the CREATE USER privilege.
     The current container must be the root container.

2)The username for the common user must be prefixed with "C##" or "c##" and contain only ASCII or EBCDIC characters.

3)The username must be unique across all containers.

4)The DEFAULT TABLESPACE, TEMPORARY TABLESPACE, QUOTA and PROFILE must all reference objects that exist in all containers.

5)You can either specify the CONTAINER=ALL clause, or omit it, as this is the default setting when the current container is the root.

The following example shows how to create common users with and without the CONTAINER clause from the root container.

CONN / AS SYSDBA

-- Create the common user using the CONTAINER clause.
CREATE USER c##test_user1 IDENTIFIED BY password1 CONTAINER=ALL;
GRANT CREATE SESSION TO c##test_user1 CONTAINER=ALL;

-- Create the common user using the default CONTAINER setting.
CREATE USER c##test_user2 IDENTIFIED BY password1;
GRANT CREATE SESSION TO c##test_user2;

Create Local Users

When creating a local user the following requirements must all be met.

1)You must be connected to a user with the CREATE USER privilege.
2)The username for the local user must not be prefixed with "C##" or "c##".
The username must be unique within the PDB.
You can either specify the CONTAINER=CURRENT clause, or omit it, as this is the default setting when the current container is a PDB.
The following example shows how to create local users with and without the CONTAINER clause from the root container.

CONN / AS SYSDBA

-- Switch container while connected to a common user.

ALTER SESSION SET CONTAINER = pdb1;

-- Create the local user using the CONTAINER clause.
CREATE USER test_user3 IDENTIFIED BY password1 CONTAINER=CURRENT;
GRANT CREATE SESSION TO test_user3 CONTAINER=CURRENT;

-- Connect to a privileged user in the PDB.
CONN system/password@pdb1

-- Create the local user using the default CONTAINER setting.
CREATE USER test_user4 IDENTIFIED BY password1;
GRANT CREATE SESSION TO test_user4;


If a local user is to be used as a DBA user, it requires the PDB_DBA role granted locally to it.

Create Common Roles

Similar to users described previously, roles can be common or local. All Oracle-supplied roles are common and therefore available in the root container and all PDBs. Common roles can be created, provided the following conditions are met.

You must be connected to a common user with CREATE ROLE and the SET CONTAINER privileges granted commonly.
1)The current container must be the root container.
2)The role name for the common role must be prefixed with "C##" or "c##" and contain only ASCII or EBCDIC characters.
3)The role name must be unique across all containers.
The role is created with the CONTAINER=ALL clause
The following example shows how to create a common role and grant it to a common and local user.

CONN / AS SYSDBA

-- Create the common role.
CREATE ROLE c##test_role1;
GRANT CREATE SESSION TO c##test_role1;

-- Grant it to a common user.
GRANT c##test_role1 TO c##test_user1 CONTAINER=ALL;

-- Grant it to a local user.
ALTER SESSION SET CONTAINER = pdb1;
GRANT c##test_role1 TO test_user3;


Only common operations can be granted to common roles. When the common role is granted to a local user, the privileges are limited to that specific user in that specific PDB.

Create Local Roles

Local roles are created in a similar manner to pre-12c databases. Each PDB can have roles with matching names, since the scope of a local role is limited to the current PDB. The following conditions must be met.

You must be connected to a user with the CREATE ROLE privilege.
If you are connected to a common user, the container must be set to the local PDB.
The role name for the local role must not be prefixed with "C##" or "c##".
The role name must be unique within the PDB.
The following example shows how to create local a role and grant it to a common user and a local user.

CONN / AS SYSDBA

-- Switch container.
ALTER SESSION SET CONTAINER = pdb1;

-- Alternatively, connect to a local or common user
-- with the PDB service.
-- CONN system/password@pdb1

-- Create the common role.
CREATE ROLE test_role1;
GRANT CREATE SESSION TO test_role1;

-- Grant it to a common user.
GRANT test_role1 TO c##test_user1;

-- Grant it to a local user.
GRANT test_role1 TO test_user3;
When a local role are granted to common user, the privileges granted via the local role are only valid when the common user has its container set to the relevant PDB.

Granting Roles and Privileges to Common and Local Users

The rules for granting privileges and roles can seem a little confusing at first. Just remember, if you connect to a PDB and only deal with local users and roles, everything feels exactly the same as pre-12c databases. It's only when you start to consider the scope of common users and roles that things become complicated.

The basic difference between a local and common grant is the value used by the CONTAINER clause.

-- Common grants.
CONN / AS SYSDBA

GRANT CREATE SESSION TO c##test_user1 CONTAINER=ALL;
GRANT CREATE SESSION TO c##test_role1 CONTAINER=ALL;
GRANT c##test_role1 TO c##test_user1 CONTAINER=ALL;

-- Local grants.
CONN system/password@pdb1
GRANT CREATE SESSION TO test_user3;
GRANT CREATE SESSION TO test_role1;
GRANT test_role1 TO test_user3;

Multitenant : Manage Tablespaces in a Container Database (CDB) and Pluggable Database (PDB) in Oracle

Manage Tablespaces in a CDB

Management of tablespaces in a container database (CDB) is no different to that of a non-CDB database. Provided you are logged in as a privileged user and pointing to the root container, the usual commands are all available.

CONN / AS SYSDBA

SQL> SHOW CON_NAME

CON_NAME
------------------------------
CDB$ROOT
SQL>

CREATE TABLESPACE dummy
  DATAFILE '/u01/app/oracle/oradata/cdb1/dummy01.dbf' SIZE 1M
  AUTOEXTEND ON NEXT 1M;
 
Tablespace created.

SQL>

ALTER TABLESPACE dummy ADD
  DATAFILE '/u01/app/oracle/oradata/cdb1/dummy02.dbf' SIZE 1M
  AUTOEXTEND ON NEXT 1M;

Tablespace altered.

SQL>

DROP TABLESPACE dummy INCLUDING CONTENTS AND DATAFILES;

Tablespace dropped.

SQL>

Manage Tablespaces in a PDB

The same tablespace management commands are available from a pluggable database (PDB), provided you are pointing to the correct container. You can connect using a common user then switch to the correct container.

SQL> CONN / AS SYSDBA
Connected.
SQL> ALTER SESSION SET CONTAINER = pdb1;

Session altered.

SQL> SHOW CON_NAME

CON_NAME
------------------------------
PDB1
SQL>
Alternatively, connect directly to the PDB as a local user with sufficient privilege.

SQL> CONN pdb_admin@pdb1
Enter password:
Connected.
SQL> SHOW CON_NAME

CON_NAME
------------------------------
PDB1
SQL>
Once pointed to the correct container, tablespaces can be managed using the same commands you have always used. Make sure you put the datafiles in a suitable location for the PDB.

CREATE TABLESPACE dummy
  DATAFILE '/u01/app/oracle/oradata/cdb1/pdb1/dummy01.dbf' SIZE 1M
  AUTOEXTEND ON NEXT 1M;
 
Tablespace created.

SQL>

ALTER TABLESPACE dummy ADD
  DATAFILE '/u01/app/oracle/oradata/cdb1/pdb1/dummy02.dbf' SIZE 1M
  AUTOEXTEND ON NEXT 1M;

Tablespace altered.

SQL>

DROP TABLESPACE dummy INCLUDING CONTENTS AND DATAFILES;

Tablespace dropped.

SQL>


Undo Tablespaces

Management of the undo tablespace in a CDB is unchanged from that of a non-CDB database.

In contrast, a PDB can not have an undo tablespace. Instead, it uses the undo tablespace belonging to the CDB. If we connect to a PDB, we can see no undo tablespace is visible.

CONN pdb_admin@pdb1

SELECT tablespace_name FROM dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
TEMP
USERS

SQL>

But we can see the datafile associated with the CDB undo tablespace.

SELECT name FROM v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/cdb1/undotbs01.dbf
/u01/app/oracle/oradata/cdb1/pdb1/system01.dbf
/u01/app/oracle/oradata/cdb1/pdb1/sysaux01.dbf
/u01/app/oracle/oradata/cdb1/pdb1/pdb1_users01.dbf

SQL>

SELECT name FROM v$tempfile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/cdb1/pdb1/temp01.dbf

SQL>


Temporary Tablespaces

Management of the temporary tablespace in a CDB is unchanged from that of a non-CDB database.

A PDB can either have its owner temporary tablespace, or if it is created without a temporary tablespace, it can share the temporary tablespace with the CBD.

CONN pdb_admin@pdb1

CREATE TEMPORARY TABLESPACE temp2
  TEMPFILE '/u01/app/oracle/oradata/cdb1/pdb1/temp02.dbf' SIZE 5M
  AUTOEXTEND ON NEXT 1M;
 
Tablespace created.

SQL>

DROP TABLESPACE temp2 INCLUDING CONTENTS AND DATAFILES;

Tablespace dropped.

SQL>


Default Tablespaces

Setting the default tablespace and default temporary tablespace for a CDB is unchanged compared to a non-CDB database.

There are a two ways to set the default tablespace and default temporary tablespace for a PDB. The ALTER PLUGGABLE DATABASE command is the recommended way.

CONN pdb_admin@pdb1
ALTER PLUGGABLE DATABASE DEFAULT TABLESPACE users;
ALTER PLUGGABLE DATABASE DEFAULT TEMPORARY TABLESPACE temp;
For backwards compatibility, it is also possible to use the ALTER DATABASE command.

CONN pdb_admin@pdb1
ALTER DATABASE DEFAULT TABLESPACE users;
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;

12c Oracle Multitenant Architecture

https://docs.oracle.com/database/121/CNCPT/cdbovrvw.htm#CNCPT89243

About the Multitenant Architecture

The multitenant architecture enables an Oracle database to function as a multitenant container database (CDB) that includes zero, one, or many customer-created pluggable databases (PDBs). A PDB is a portable collection of schemas, schema objects, and nonschema objects that appears to an Oracle Net client as a non-CDB. All Oracle databases before Oracle Database 12c were non-CDBs
Every CDB has the following containers:
  • Exactly one root
    The root stores Oracle-supplied metadata and common users. An example of metadata is the source code for Oracle-supplied PL/SQL packages (see "Data Dictionary Architecture in a CDB"). A common user is a database user known in every container (see "Common Users in a CDB"). The root container is named CDB$ROOT.
  • Exactly one seed PDB
    The seed PDB is a system-supplied template that the CDB can use to create new PDBs. The seed PDB is named PDB$SEED. You cannot add or modify objects in PDB$SEED.
  • Zero or more user-created PDBs
    A PDB is a user-created entity that contains the data and code required for a specific set of features. For example, a PDB can support a specific application, such as a human resources or sales application. No PDBs exist at creation of the CDB. You add PDBs based on your business requirements.
The following graphic shows a CDB with four containers: the root, seed, and two PDBs. Each PDB has its own dedicated application. A different PDB administrator manages each PDB. A common user exists across a CDB with a single identity. In this example, common user SYS can manage the root and every PDB. At the physical level, this CDB has a database instance and database files, just as a non-CDB does.
Description of cncpt345.png follows





Creation of a CDB

The CREATE DATABASE ... ENABLE PLUGGABLE DATABASE SQL statement creates a new CDB. If you do not specify the ENABLE PLUGGABLE DATABASE clause, then the newly created database is a non-CDB and can never contain PDBs.


Description of admin095.png follows


Example 17-1 Determining Whether a Database Is a CDB
SQL> SELECT NAME, CDB, CON_ID FROM V$DATABASE;
 
NAME      CDB     CON_ID
--------- --- ----------
CDB1      YES          0

Creation of a PDB

The CREATE PLUGGABLE DATABASE SQL statement creates a PDB. This PDB automatically includes a full data dictionary including metadata and internal links to system-supplied objects in the root. You can only create a PDB in a CDB and not within another PDB.
The following graphic depicts the options for creating a PDB:
Description of cncpt358.png follows

Creation of a PDB

The CREATE PLUGGABLE DATABASE SQL statement creates a PDB. This PDB automatically includes a full data dictionary including metadata and internal links to system-supplied objects in the root. You can only create a PDB in a CDB and not within another PDB.
The following graphic depicts the options for creating a PDB:
Description of cncpt358.png follows

The following sections describe the different techniques for creating PDBs.

1Creation of a PDB from Seed

You can use the CREATE PLUGGABLE DATABASE statement to create a PDB by copying the files from PDB$SEED, which is a template for creating PDBs. The following graphic illustrates creation from the seed:
CREATE PLUGGABLE DATABASE hrpdb
ADMIN USER dba1 identfiied by password

2 Creation of a PDB by Cloning a PDB or a Non-CDB

You can use the CREATE PLUGGABLE DATABASE statement to clone a source PDB or non-CDB and plug the clone into the CDB. The source can be a PDB in a local or remote CDB, or starting in Oracle Database 12c Release 1 (12.1.0.2), it can also be a remote non-CDB. This technique copies the files associated with the source PDB or non-CDB to a new location and associates the copied files with the new PDB.
CREATE PLUGGABLE DATABASE salepdb from hrpdb

3 Creation of a PDB by Plugging in an Unplugged PDB

In its unplugged state, a PDB is a self-contained set of data files and an XML metadata file. This technique uses the XML metadata file that describes the PDB and the files associated with the PDB to associate it with the CDB. The following graphic illustrates plugging in an unplugged PDB:
CREATE PLUGGABLE DATABASE salespdb USING '/disk1/usr/financepdb.xml' NOCOPY


Creation of a PDB from a Non-CDB

Execute DBMS_PDB.DESCRIBE on a non-CDB in Oracle Database 12c