Create & Plug and Unplug PDB's
To Create PDB's the following methods can be followed
Copying
- From PDB Seed
Cloning from a existing PDB using
- Locally
- Remotely through DB Link
Plugging in
- Plugging in an unplugged DB (unplug and plug as database into same container database)
- Plugging in a NON-CDB as a PDB (NON-CDB database converting to PDB database into a container database)
Before getting Started the options or clauses using for Create/Alter Pluggable database are
Storage Limits :- You can specify the limit of the size of the PDB you create
MAX_SIZE = The amount of storage that can be used by all tablespaces that belong to the PDB
MAX_SHARED_TEMP_SIZE = The amount of storage in the default temporary tablespace shared by all PDBs that can be used by sessions connected to the PDB
File Locations
PATH_PREFIX = Restricting the PDB to specified directory so that all files placed in this directory
Example:- PATH_PREFIX = '/disk1/oracle/dbs/salespdb/'FILE_NAME_CONVERT = Convert the location of the files to this location while creating PDB
Example:- FILE_NAME_CONVERT = ('/oracle/dbs/', '/oracle/pdb5/')
Note: If this parameter is not set, Oracle looks for pdb_file_name_convert parameter and converts accordingly
SOURCE_FILE_NAME_CONVERT= When unplugging and plugging databases, Using this parameter will convert the names of the files that different of XML
SOURCE_FILE_NAME_CONVERT = ('/disk1/oracle/pdb7/', '/disk2/oracle/pdb7/')
Temp File Reuse
TEMPFILE Reuse:- Clause reuse the temp file in the location that PDB going to create.
Snapshot copy
Examples:-
Task | Method | Description | Command |
Create PDB | Copying From Seed PDB | creates a PDB (Assuming OMF is enabled or PDB_FILE_NAME_CONVERT is specified) | SQL> CREATE PLUGGABLE DATABASE salespdb ADMIN USER salesadm IDENTIFIED BY password; |
Copying From Seed PDB | creates a PDB with a pdb dba role assigned to user | SQL> CREATE PLUGGABLE DATABASE salespdb ADMIN USER salesadm IDENTIFIED BY password ROLES=(DBA); | |
Copying From Seed PDB |
|
SQL> CREATE PLUGGABLE DATABASE salespdb ADMIN USER salesadm IDENTIFIED BY password |
|
Cloning DB Local | Example clones a PDB1 to PDB2 | SQL> CREATE PLUGGABLE DATABASE pdb2 FROM pdb1; | |
example clones a PDB1 to PDB2 with the path_prefix changes and changing the file name paths | SQL> CREATE PLUGGABLE DATABASE pdb2 FROM pdb1 PATH_PREFIX = '/disk2/oracle/pdb2' FILE_NAME_CONVERT = ('/disk1/oracle/pdb1/', '/disk2/oracle/pdb2/'); |
||
Cloning from local PDB with storage limit clauses |
SQL> CREATE PLUGGABLE DATABASE pdb2 FROM pdb1 |
||
Clone DB from Remote | Creates a PDB from a remote PDB | SQL CREATE PLUGGABLE DATABASE pdb2 FROM pdb1@pdb1_link; | |
Plugging IN | Unplug and plug as new | To unplug first check the compatibility and also to flat xml file |
set serveroutput on DECLARE |
Plug the database using NOCOPY Means all the datafiles should be in same location no copy required |
create pluggable database pdb_plug_nocopy using '/u01/app/oracle/oradata/pdb1.xml' Verify the status select pdb_name, status from cdb_pdbs where pdb_name='PDB_PLUG_COPY'; select open_mode from v$pdbs where name='PDB_PLUG_COPY'; alter pluggable database pdb_plug_nocopy open; |
||
Plug the database using COPY method Means all the datafiles should be copied from location to target location |
mkdir /u01/app/oracle/oradata/cdb2/pdb_plug_copy sqlplus / as sysdba
create pluggable database pdb_plug_copy using '/u01/app/oracle/oradata/pdb2.xml' Verify the status select pdb_name, status from cdb_pdbs where pdb_name='PDB_PLUG_COPY'; select open_mode from v$pdbs where name='PDB_PLUG_COPY'; alter pluggable database pdb_plug_copy open; |
||
Plug the database using MOVE method when cloning |
mkdir /u01/app/oracle/oradata/cdb2/pdb_plug_move sqlplus / as sysdba create pluggable database pdb_plug_move Verify the status select pdb_name, status from cdb_pdbs where pdb_name='PDB_PLUG_MOVE'; select open_mode from v$pdbs where name='PDB_PLUG_MOVE';
alter pluggable database pdb_plug_move open; |
||
Unplugging | Unplug database from CDB | Unplug and export to Flat xml file |
|
Convert NON-CDB database to PDB | Convert NON-CDB database to PDB | 1) Upgrade the Non-CDB if the database is pre 12c 2) Open the database in readonly 3) Execute DBMS_PDB 4) Use Create Pluggable database 5) Execute the script noncdb_to_pdb.sql |
1) Upgrade and set comptabile = 12.0.0 2) OPen the database in readonly mode 3) Execute the dbms_pdb package describe procedure BEGIN DBMS_PDB.DESCRIBE( pdb_descr_file => '/disk1/oracle/ncdb.xml'); END; / 4) Shutdown the non-cdb database 5) If in same server your CDB database contains CREATE PLUGGABLE DATABASE ncdb USING '/disk1/oracle/ncdb.xml' COPY FILE_NAME_CONVERT = ('/disk1/oracle/dbs/', '/disk2/oracle/ncdb/'); 6) Execute the script @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql 7) Open the read write mode new PDB |
Follow Me!!!