Creating a PDB from a local PDB

In this post I will be showing a simple example of how to create a PDB database through a local PDB:
Then follow the examples:

1-The database must be CDB and you must be connected in the CDB$ROOT:

	
[oracle@dbdg admin]$ sqlplus "/as sysdba" 

SQL*Plus: Release 12.1.0.2.0 Production on Wed Mar 14 15:46:02 2018

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

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

SQL> select cdb, name from v$database;

CDB NAME
--- ---------
YES CDB4

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT

2-Create the PDB through the local PDB (which should be open in read-only mode:

 
SQL> set pages 9999   
SQL> select name, open_mode from v$database;

NAME	  OPEN_MODE
--------- --------------------
CDB4	  READ WRITE

SQL> set pages 9999
SQL> select name, open_mode from v$pdbs;

NAME			       OPEN_MODE
------------------------------ ----------
PDB$SEED		       READ ONLY
PDBCDB4 		       READ WRITE
CDBSEED 		       READ WRITE
CDBSEED2		       MOUNTED
MIG			       READ WRITE
NONCDB			       READ WRITE
TECHDATABASKET		       READ WRITE

7 rows selected.

– As we will be using the PDB TECHDATABASKET in this example, the next step will be to put this PDB in READ ONLY mode:

— Como estaremos utilizando o PDB TECHDATABASKET neste exemplo, o próximo passo será colocar o mesmo no modo READ ONLY:


SQL> ALTER PLUGGABLE DATABASE TECHDATABASKET  CLOSE;

Pluggable database altered.

SQL> ALTER PLUGGABLE DATABASE TECHDATABASKET OPEN READ ONLY;

Pluggable database altered.

SQL> SET PAGES 9999
SQL> select name, open_mode from v$pdbs;

NAME			       OPEN_MODE
------------------------------ ----------
PDB$SEED		       READ ONLY
PDBCDB4 		       READ WRITE
CDBSEED 		       READ WRITE
CDBSEED2		       MOUNTED
MIG			       READ WRITE
NONCDB			       READ WRITE
TECHDATABASKET		       READ ONLY

7 rows selected.

	
SQL>  CREATE PLUGGABLE DATABASE techdatabasket2 from techdatabasket FILE_NAME_CONVERT=('/u01/app/oracle/oradata/cdb4/techdatabasket','/u01/app/oracle/oradata/cdb4/techdatabasket2');

Pluggable database created.

3-Open the new PDB in read/write mode:


SQL> SET PAGES 9999
SQL> select name, open_mode from v$pdbs;

NAME			       OPEN_MODE
------------------------------ ----------
PDB$SEED		       READ ONLY
PDBCDB4 		       READ WRITE
CDBSEED 		       READ WRITE
CDBSEED2		       MOUNTED
MIG			       READ WRITE
NONCDB			       READ WRITE
TECHDATABASKET		       READ ONLY
TECHDATABASKET2 	       MOUNTED

8 rows selected.

SQL> ALTER PLUGGABLE DATABASE TECHDATABASKET2 OPEN READ WRITE;

Pluggable database altered.

4- Check the status of the new PDB and open the source PDB in READ WRITE mode:


SQL> ALTER PLUGGABLE DATABASE TECHDATABASKET CLOSE;

Pluggable database altered.

SQL> ALTER PLUGGABLE DATABASE TECHDATABASKET OPEN READ WRITE;

Pluggable database altered.

	
SQL> select name, open_mode from v$pdbs;

NAME			       OPEN_MODE
------------------------------ ----------
PDB$SEED		       READ ONLY
PDBCDB4 		       READ WRITE
CDBSEED 		       READ WRITE
CDBSEED2		       MOUNTED
MIG			       READ WRITE
NONCDB			       READ WRITE
TECHDATABASKET		       READ ONLY
TECHDATABASKET2 	       READ WRITE

8 rows selected.


1-O banco de dados deve ser CDB e estar conectado no CDB$ROOT

	
[oracle@dbdg admin]$ sqlplus "/as sysdba" 

SQL*Plus: Release 12.1.0.2.0 Production on Wed Mar 14 15:46:02 2018

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

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

SQL> select cdb, name from v$database;

CDB NAME
--- ---------
YES CDB4

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT

2-Criar o PDB através do PDB local (que deverá estar aberto no modo read-only:

 

 
SQL> set pages 9999   
SQL> select name, open_mode from v$database;

NAME	  OPEN_MODE
--------- --------------------
CDB4	  READ WRITE

SQL> set pages 9999
SQL> select name, open_mode from v$pdbs;

NAME			       OPEN_MODE
------------------------------ ----------
PDB$SEED		       READ ONLY
PDBCDB4 		       READ WRITE
CDBSEED 		       READ WRITE
CDBSEED2		       MOUNTED
MIG			       READ WRITE
NONCDB			       READ WRITE
TECHDATABASKET		       READ WRITE

7 rows selected.

— Como estaremos utilizando o PDB TECHDATABASKET neste exemplo, o próximo passo será colocar o mesmo no modo READ ONLY:


SQL> ALTER PLUGGABLE DATABASE TECHDATABASKET  CLOSE;

Pluggable database altered.

SQL> ALTER PLUGGABLE DATABASE TECHDATABASKET OPEN READ ONLY;

Pluggable database altered.

SQL> SET PAGES 9999
SQL> select name, open_mode from v$pdbs;

NAME			       OPEN_MODE
------------------------------ ----------
PDB$SEED		       READ ONLY
PDBCDB4 		       READ WRITE
CDBSEED 		       READ WRITE
CDBSEED2		       MOUNTED
MIG			       READ WRITE
NONCDB			       READ WRITE
TECHDATABASKET		       READ ONLY

7 rows selected.

	
SQL>  CREATE PLUGGABLE DATABASE techdatabasket2 from techdatabasket FILE_NAME_CONVERT=('/u01/app/oracle/oradata/cdb4/techdatabasket','/u01/app/oracle/oradata/cdb4/techdatabasket2');

Pluggable database created.

3-Abrir o novo PDB no modo read/write:


SQL> SET PAGES 9999
SQL> select name, open_mode from v$pdbs;

NAME			       OPEN_MODE
------------------------------ ----------
PDB$SEED		       READ ONLY
PDBCDB4 		       READ WRITE
CDBSEED 		       READ WRITE
CDBSEED2		       MOUNTED
MIG			       READ WRITE
NONCDB			       READ WRITE
TECHDATABASKET		       READ ONLY
TECHDATABASKET2 	       MOUNTED

8 rows selected.

SQL> ALTER PLUGGABLE DATABASE TECHDATABASKET2 OPEN READ WRITE;

Pluggable database altered.

4- Verificar o status do novo PDB e abrir o source PDB no modo READ WRITE:


SQL> ALTER PLUGGABLE DATABASE TECHDATABASKET CLOSE;

Pluggable database altered.

SQL> ALTER PLUGGABLE DATABASE TECHDATABASKET OPEN READ WRITE;

Pluggable database altered.

SQL> select name, open_mode from v$pdbs;

NAME			       OPEN_MODE
------------------------------ ----------
PDB$SEED		       READ ONLY
PDBCDB4 		       READ WRITE
CDBSEED 		       READ WRITE
CDBSEED2		       MOUNTED
MIG			       READ WRITE
NONCDB			       READ WRITE
TECHDATABASKET		       READ ONLY
TECHDATABASKET2 	       READ WRITE

8 rows selected.

Related posts

Leave a Comment