16 Multitenant Container Databases

Using CDBs

To manage the multitenant architecture from Visual Studio, connect as SYSDBA in Server Explorer to a CDB.

Once connected, you should see a Pluggable Databases Node. If you do not see it, you may not have SYSDBA privileges, the database may not be 12.1 or higher, or you may have accidentally connected to a PDB instead of a CDB.

This node has context sensitive menus including:

  • New Pluggable Database: Opens the New Pluggable Database Dialog and allows you to create a new PDB based on the seed PDB. At the end of this operation, if the option is chosen in the General Options Page, a new connection to the PDB is made in Server Explorer, and if the CDB used a TNS connection, a connection alias for the PDB is added to the tnsnames.ora file.

  • Plug: Opens the Plug Pluggable Database Dialog which accepts paths to an XML metadata file as well as to database files on the same computer as the CDB. Once plugged in, the PDB is visible to the other PDBs in Server Explorer. The PDB must have the same character set as the CDB or this operation will fail.

When the Pluggable Databases Node is expanded, child Pluggable Database Nodes are shown, one for each PDB. Each of these Pluggable Database nodes have menu options that allow the following operations.

  • Clone: Opens the Clone Pluggable Database Dialog and makes a clone of the PDB. At the end of this operation, if the option is chosen in the General Options Page, a new connection to the PDB is made in Server Explorer, and if the CDB used a TNS connection, a connection alias for the PDB is added to the tnsnames.ora file.

  • Unplug: Opens the Unplug Pluggable Database Dialog, creates an XML metadata file, and removes the PDB from the CDB. The PDB then exists only as a set of files on the server filesystem.

  • Close: Opens the Close Pluggable Database Dialog. Performs the equivalent of a non-CDB database SHUTDOWN.

  • Open: Opens the Open Pluggable Database Dialog. Opens the PDB so that it is accessible to users.

  • Delete: Deletes the PDB from the CDB and removes its files from the server.

Connecting to a PDB in Server Explorer

If the option is enabled in General Options Page, creating a new PDB or cloning one using ODT results in a connection being made in Server Explorer using the administrator account, and if applicable, a connect alias being added to the tnsnames.ora file.

To manually connect to a PDB, you will need the hostname, port number, and database service name of the container database. Then you can connect to the PDB using the same hostname and port number and a database service name that consist of the pluggable database name followed by the remainder of the container database service name identifier.

For example: If a CDB is identified by:

Host: myhost.oracle.com

Port: 1521

Database Service Name: CONTAINERDB.oracle.com

and the PDB is named PDBORCL,

then the PDB could be connected to using the following information:

Host: myhost.oracle.com

Port: 1521

Database Service Name: PDBORCL.oracle.com

PDB and CDB Compatibility

To plug a PDB into a CDB, they must meet the following requirements:

  • They must use the same character set.

  • They must have the same endianness.

  • The original CDB, which created the PDB, and the target CDB must have the same set of database options installed.

To verify if a PDB is compatible with a given CDB, execute the following SQL*Plus script as SYSDBA while connected to the CDB and with the database files copied to the server:

SET SERVEROUTPUT ON
DECLARE
  compatible CONSTANT VARCHAR2(3) :=
    CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
           pdb_descr_file => '<<<PDB PATH>>>',
           pdb_name       => '<<<PDB NAME>>>')
    WHEN TRUE THEN 'YES'
    ELSE 'NO'
END;
BEGIN
  DBMS_OUTPUT.PUT_LINE(compatible);
END;
/
select type, message from PDB_PLUG_IN_VIOLATIONS where name=''<<<PDB NAME>>>';

See Also:

Oracle Database Administrator's Guide for more information on PDB and CDB compatibility