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.
Hi! I am Bruno, a Brazilian born and bred, and I am also a naturalized Swedish citizen. I am a former Oracle ACE and, to keep up with academic research, I am a Computer Scientist with an MSc in Data Science and another MSc in Software Engineering. I have over ten years of experience working with companies such as IBM, Epico Tech, and Playtech across three different countries (Brazil, Hungary, and Sweden), and I have joined projects remotely in many others. I am super excited to share my interests in Databases, Cybersecurity, Cloud, Data Science, Data Engineering, Big Data, AI, Programming, Software Engineering, and data in general.
(Continue reading)