10 Creating a PDB as a Proxy PDB

You can create a PDB as a proxy PDB by referencing it in a remote CDB.

10.1 About Creating a Proxy PDB

A proxy PDB provides access to a PDB in a remote CDB. It is analogous to a symbolic link.

The CREATE PLUGGABLE DATABASE statement creates a proxy PDB by referencing a PDB in a different CDB, which is called the referenced PDB. You can use a proxy PDB when you want a local context for a remote PDB. In addition, when application containers in different CDBs have the same application, you can keep their application roots synchronized with a proxy PDB.

To use this technique, run the CREATE PLUGGABLE DATABASE statement in the CDB that will contain the proxy PDB. You must include:

  • The AS PROXY clause to specify that you are creating a proxy PDB.

  • A FROM clause that specifies the PDB that the proxy PDB is referencing.

  • A database link to the current location of the referenced PDB in the FROM clause. The database link must be created in the root of the CDB that will contain the proxy PDB, and the database link connects either to the root of remote CDB or to the remote referenced PDB.

The following figure illustrates how this technique creates a proxy PDB that references a PDB in a remote CDB.

Figure 10-1 Create a Remote Proxy PDB

Description of Figure 10-1 follows
Description of "Figure 10-1 Create a Remote Proxy PDB"

You can create a proxy PDB in an application container. To do so, the referenced PDB must be an application root or an application PDB in an application container in a different CDB. The database link must be created in the root of the application container that will contain the proxy PDB, and the database link connects either to the root of remote application container or to the remote referenced application PDB.

The following graphic illustrates how this technique creates a proxy PDB in an application container based on a remote referenced PDB in an application container.

Figure 10-2 Create a Remote Proxy PDB in an Application Container

Description of Figure 10-2 follows
Description of "Figure 10-2 Create a Remote Proxy PDB in an Application Container"

Before creating a proxy PDB, address the questions that apply to creating a proxy PDB in "Table 5-3". The table describes which CREATE PLUGGABLE DATABASE clauses you must specify based on different factors.

10.1.1 Proxy PDBs and SQL Statements

As a rule, when the proxy PDB is the current container, SQL statements submitted for execution in the proxy PDB are executed in the referenced PDB.

The results of the remote execution are returned to the proxy PDB. For example, data definition language (DDL) statements, data manipulation language (DML) statements, and queries executed in the proxy PDB are sent to the referenced PDB for execution, and the results are returned to the proxy PDB.

There is one exception to the rule. When the proxy PDB is the current container, and when you execute ALTER PLUGGABLE DATABASE and ALTER DATABASE statements, these statements only affect the proxy PDB. They are not sent to the referenced PDB for execution. Similarly, when the current container is the root to which the proxy PDB belongs, ALTER PLUGGABLE DATABASE statements only affect the proxy PDB. For example, an ALTER PLUGGABLE DATABASE statement executed in a CDB root, application root, or proxy PDB can open or close a proxy PDB, but this statement does not open or close the referenced PDB.

10.1.2 Proxy PDBs and Database Links

A database link is required when you create a proxy PDB.

After the proxy PDB is created, the database link specified during creation is no longer used by the proxy PDB. Instead, the proxy PDB communicates directly with the referenced PDB.

This direct communication requires the port number and host name of the listener of the CDB that contains the referenced PDB. During proxy PDB creation, the proxy PDB uses the following values by default:

  • Listener port number: 1521

    If the referenced PDB’s listener does not use the default port number, then you must use the PORT clause to specify the listener’s port number. You can specify the port number when you create the proxy PDB, or you can alter the proxy PDB to change the port number.

  • Listener host name: The host name of the CDB that contains the referenced PDB

    If the referenced PDB’s listener does not use the default host name, then you must use the HOST clause to specify the listener’s host name. You can specify the host name when you create the proxy PDB, or you can alter the proxy PDB to change the host name.

10.1.3 Proxy PDBs and Authentication

Only password authentication is supported for sessions in a proxy PDB.

10.1.4 Proxy PDBs and the Listener

The host name and port number settings for a PDB are important only if proxy PDBs will reference the PDB.

10.1.4.1 HOST Clause

The HOST clause of the CREATE PLUGGABLE DATABASE statement specifies the host name of the listener for the PDB being created.

By default, the host name of the listener is the same as the host name of the PDB being created. Specify the HOST clause when both of the following conditions are true:

  • The host name of the listener is different from the host name of the PDB being created.

  • You plan to create proxy PDBs that reference the PDB being created.

A proxy PDB uses a database link to establish communication with its referenced PDB. After communication is established, the proxy PDB communicates directly with the referenced PDB without using a database link. The host name of the listener must be correct for the proxy PDB to function properly.

Example 10-1 HOST Clause

HOST='myhost.example.com'
10.1.4.2 PORT Clause

The PORT clause of the CREATE PLUGGABLE DATABASE statement specifies the port number of the listener for the PDB being created.

By default, the port number of the listener for the PDB being created is 1521. Specify the PORT clause when both of the following conditions are true:

  • The port number of the listener is not 1521.

  • You plan to create proxy PDBs that reference the PDB being created.

A proxy PDB uses a database link to establish communication with its referenced PDB. After communication is established, the proxy PDB communicates directly with the referenced PDB without using a database link. The port number of the listener must be correct for the proxy PDB to function properly.

Example 10-2 PORT Clause

PORT=1599

10.2 Creating a Proxy PDB

Create a proxy PDB by referencing a PDB in a different CDB.

Prerequisites

The following prerequisites must be met:

  • Complete the prerequisites described in "General Prerequisites for PDB Creation".

  • The current user must have the CREATE PLUGGABLE DATABASE system privilege in the root of the CDB in which the proxy PDB is being created.

  • The CDB that contains the referenced PDB must be in local undo mode.

  • The CDB that contains the referenced PDB must be in ARCHIVELOG mode.

  • The referenced PDB must be in open read/write mode when the proxy PDB is created. The open mode of the referenced PDB can be changed after the proxy PDB is created.

  • A database link must enable a connection from the root of the CDB in which the proxy PDB is being created to the location of the referenced PDB. The database link can connect to either the root of the remote CDB or to the remote PDB.

  • If the database link connects to the root in a remote CDB that contains the referenced PDB, then the user that the database link connects with must be a common user.

  • If the database link connects to the referenced PDB, then the user that the database link connects with in the referenced PDB must have the CREATE PLUGGABLE DATABASE system privilege.

  • If you are creating a proxy PDB in an application container, then the following prerequisites apply:
    • The referenced PDB must be an application root or an application PDB in an application container.

    • The application name and version of the proxy PDB’s application container must match the application name and version of the referenced PDB.

    • When the proxy PDB is being created in an application container, a database link must enable a connection from the root of the application container in which the proxy PDB is being created to the location of the referenced PDB. The database link can connect to either the root of the remote application container or to the remote application PDB.

    • If the database link connects to the root in a remote application container that contains the referenced PDB, then the user that the database link connects with must be an application common user.

    • If the database link connects to the referenced application PDB, then the user that the database link connects with in the referenced application PDB must have the CREATE PLUGGABLE DATABASE system privilege.

    Note:

    You can create a proxy PDB in a CDB root that is based on a referenced PDB in an application container.

To create a proxy PDB:

  1. In SQL*Plus, ensure that the current container is the CDB root or application root in which the proxy PDB is being created.

    When the current container is the CDB root, the proxy PDB is created in the CDB. When the current container is an application root, the proxy PDB is created in the application container.

  2. Run the CREATE PLUGGABLE DATABASE statement. Specify the AS PROXY clause, and specify the referenced PDB with the database link name in the FROM clause. Specify other clauses when they are required.

    After you create the proxy PDB, it is in mounted mode, and its status is NEW. You can view the open mode of a PDB by querying the OPEN_MODE column in the V$PDBS view. You can view the status of a PDB by querying the STATUS column of the CDB_PDBS or DBA_PDBS view.

    A new default service is created for the PDB. The service has the same name as the PDB and can be used to access the PDB. Oracle Net Services must be configured properly for clients to access this service.

  3. Open the new PDB in read/write mode.

    You must open the new PDB in read/write mode for Oracle Database to complete the integration of the new PDB into the CDB. An error is returned if you attempt to open the PDB in read-only mode. After the PDB is opened in read/write mode, its status is NORMAL.

  4. Back up the PDB.

    A PDB cannot be recovered unless it is backed up.

Note:

If an error is returned during creation of the proxy PDB, then the PDB being created might be in an UNUSABLE state. You can check a PDB's state by querying the CDB_PDBS or DBA_PDBS view, and you can learn more about PDB creation errors by checking the alert log. An unusable PDB can only be dropped, and it must be dropped before a PDB with the same name as the unusable PDB can be created.

Example 10-3 Creating a Remote Proxy PDB

In this example, the root to which the new PDB belongs depends on the current container when the CREATE PLUGGABLE DATABASE statement is run:

  • When the current container is the CDB root, the new PDB is created in the CDB root.

  • When the current container is an application root in an application container, the new PDB is created as an application PDB in the application root.

This example creates a remote proxy PDB named pdb1 given different factors. This example assumes the following factors:

  • The database link name to the referenced PDB’s CDB is pdb1_link.

  • The FILE_NAME_CONVERT clause and the CREATE_FILE_DEST clause are not required.

    Either Oracle Managed Files is enabled, or the PDB_FILE_NAME_CONVERT initialization parameter is set. The SYSTEM and SYSAUX files will be copied to a new location based on the Oracle Managed Files configuration or the initialization parameter setting.

Given the preceding factors, the following statement creates the pdb1 proxy PDB:

CREATE PLUGGABLE DATABASE pdb1 AS PROXY FROM pdb1@pdb1_link;