3 Utilizing the Multitenant Architecture

This chapter outlines the installation choices and different scenarios associated with copying and moving pluggable databases introduced by the Oracle Database 12c multitenant architecture with respect to Oracle Application Express (Application Express).

3.1 Understanding Installation Choices in Oracle Database 12c

Oracle Database 12c Release 1 (12.1) introduces the multitenant architecture. This database architecture has a multitenant container database (CDB) that includes a root container, CDB$ROOT, a seed database, PDB$SEED, and multiple pluggable databases (PDBs). Each pluggable database is equivalent to a separate database instance in Oracle Database release 11g. The root container, CDB$ROOT, holds common objects that are accessible to every PDB utilizing metadata links or object links. The seed database, PDB$SEED, is used when creating a new PDB to seed the new database. The key benefit of the Oracle Database 12c multitenant architecture is that the database resources, such as CPU and memory, can be shared across all of the PDBs. This architecture also enables many databases to be treated as one for tasks such as upgrades or patches, and backups.

Oracle Application Express Release 4.2 is the earliest release that can be configured with Oracle Database 12c. When choosing to install Oracle Database 12c using the Oracle Database 12c multitenant architecture, Oracle Application Express 4.2.4 is installed as a common database option by default. You may also choose to uninstall Application Express from the root container and then install a local Application Express Release 4.2.4 or later individually into one or more PDBs. Oracle does not support uninstalling Application Express from the root container, or reinstalling Application Express into the root container, once any PDBs have been configured. This may invalidate or completely remove the meta data associated with the existing Application Express installation.

When configuring multitenant architecture, Oracle Application Express is installed in the root container database by default. In such an installation the root container, CDB$ROOT, includes the APEX_040200 schema to store the common database objects for the Application Express engine such as packages, functions, procedures and views. The seed database, PDB$SEED, also includes the APEX_040200 schema to store the tables that are part of the Application Express engine.

You can create a new PDB by copying PDB$SEED, which includes the APEX_040200 schema with the Application Express tables, and creating metadata links back to the common database objects held in the APEX_040200 schema within the CDB$ROOT. As such there are multiple copies of the Application Express engine tables and only single copies of the Application Express engine packages, functions, procedures and views. Each PDB will have the APEX_040200 schema and have its own copy of the Application Express engine's tables so that it can hold the metadata for the Application Express applications defined within that PDB.

As a best practice, Oracle recommends having a common Oracle Application Express installation in the root container, which ensures every PDB is running the same version of Oracle Application Express. This offers ease of administration by enabling centralized management of Oracle Application Express infrastructure tasks, such as upgrading and patching. The other alternative is to uninstall Application Express from CDB$ROOT, PDB$SEED, and all other PDBs, and then install Application Express locally into each PDB. The advantage of a local Oracle Application Express is that you can run different versions of Application Express in each PDB. However, the disadvantage of choosing this option is that each local Oracle Application Express installation must be managed separately in respect of upgrades and patches for Application Express, which is a greater maintenance effort.

3.1.1 Uninstalling Application Express from a CDB

To have the flexibility of installing different versions of Oracle Application Express into different PDBs, you need to uninstall Oracle Application Express release 4.2.4 which was installed into the container database. Once you have removed Oracle Application Express from the container database, then you can install a local Application Express within each PDB as required. When Oracle Application Express is installed locally there are no Application Express metadata linked objects and all packages, views, and tables are created within the APEX_0402000 schema, within each PDB where Application Express is installed.

To uninstall Oracle Application Express from the CDB:

  1. Change your working directory to $ORACLE_HOME/apex.

  2. Start SQL*Plus and connect to the database where Oracle Application Express is installed as SYS specifying the SYSDBA role. For example:

    • On Windows:

      SYSTEM_DRIVE:\ sqlplus /nolog
      SQL> CONNECT SYS as SYSDBA
      Enter password: SYS_password
      
    • On UNIX and Linux:

      $ sqlplus /nolog
      SQL> CONNECT SYS as SYSDBA
      Enter password: SYS_password
      
  3. Run apxremov_con.sql.

    For example:

    @apxremov_con.sql
    

    Note:

    If you run apexremov_con.sql after PDBs have been added to the CDB then Application Express uninstalls from all of the PDBs. Therefore, any applications defined in any of the PDBs will be removed. If you run apxremov.sql then Application Express is only removed from the root container. However, every PDB is left in an invalid state and will cause errors when trying to open the PDB.

3.1.2 Installing Application Express Locally in a PDB

Once you have removed Oracle Application Express from the container database by following the instructions in "Uninstalling Application Express from a CDB", you can install Application Express locally in a PDB.

To install Oracle Application Express locally in a PDB:

  1. Change your working directory to $ORACLE_HOME/apex.

  2. Start SQL*Plus and connect to the database where Oracle Application Express is installed as SYS specifying the SYSDBA role. For example:

    • On Windows:

      SYSTEM_DRIVE:\ sqlplus /nolog
      SQL> CONNECT SYS as SYSDBA
      Enter password: SYS_password
      
    • On UNIX and Linux:

      $ sqlplus /nolog
      SQL> CONNECT SYS as SYSDBA
      Enter password: SYS_password
      
  3. Set the container to the PDB you wish to install Application Express locally:

    ALTER SESSION SET CONTAINER = <PDB_name>;
    
  4. Select the appropriate installation option.

    Full development environment provides complete access to the Application Builder environment to develop applications. A Runtime environment enables users to run applications that cannot be modified. To learn more, see "About the Oracle Application Express Runtime Environment".

    Available installation options include:

    • Full development environment - Run apexins.sql passing the following four arguments in the order shown:

      @apexins.sql tablespace_apex tablespace_files tablespace_temp images
      

      Where:

      • tablespace_apex is the name of the tablespace for the Oracle Application Express application user.

      • tablespace_files is the name of the tablespace for the Oracle Application Express files user.

      • tablespace_temp is the name of the temporary tablespace or tablespace group.

      • images is the virtual directory for Oracle Application Express images. To support future Oracle Application Express upgrades, define the virtual image directory as /i/.

      For example:

      @apexins.sql SYSAUX SYSAUX TEMP /i/
      
    • Runtime environment - Run apxrtins.sql passing the following four arguments in the order shown:

      o @apxrtins.sql tablespace_apex tablespace_files tablespace_temp images
      

      Where:

      • tablespace_apex is the name of the tablespace for the Oracle Application Express application user.

      • tablespace_files is the name of the tablespace for the Oracle Application Express files user.

      • tablespace_temp is the name of the temporary tablespace or tablespace group.

      • images is the virtual directory for Oracle Application Express images. To support future Oracle Application Express upgrades, define the virtual image directory as /i/.

      For example:

      @apxrtins.sql SYSAUX SYSAUX TEMP /i/
      

    Note:

    If you did not apply the database patch prior to executing apxremov_con.sql in the previous step, then attempting to install Oracle Application Express into a PDB will fail as the installation script will exit immediately without installing Oracle Application Express. In this scenario please contact Oracle Support for further assistance.