8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » Misc » Here

APEXExport : Export APEX Applications and Workspaces From the Command Line

Transferring APEX applications and workspaces between environments is done using SQL scripts containing calls to the WWV_FLOW_API package. These can be checked into source control, and ultimately used as the source for deployments to other environments. Rather than manually exporting applications and workspaces, which risks accidentally picking incorrect options, you may decide to script the export using the APEXExport utility. This article describes how to use the APEXExport utility to export applications and workspaces.

Related articles.

Software

You will need the APEX software and a copy of the "ojdbc8.jar" file. You can download ojdbc8.jar, or copy it from an existing product such as SQL Developer.

Identify Applications

The APEX_APPLICATIONS view displays information about the APEX applications.

-- Connect to the workspace user.
conn dev_ws/dev_ws@//localhost:1521/pdb1

COLUMN workspace FORMAT A20
COLUMN workspace_id FORMAT 99999999999999999999
COLUMN application_id FORMAT A14
COLUMN application_name FORMAT A20

-- List applications.
SELECT workspace,
       workspace_id,
       application_id,
       application_name
FROM   apex_applications
ORDER BY 1;

WORKSPACE          WORKSPACE_ID APPLICATION_ID APPLICATION_NAM
--------- --------------------- -------------- ---------------
DEV_WS         2600821031139055            101 Demo App

SQL>

Windows Example

Place the software into a directory of your choice. In this example we will use the "C:\temp" directory.

Unzip the APEX software and copy the "ojdbc8.jar" file to the utilities directory.

cd c:\temp
unzip apex_20.1_en.zip
copy ojdbc8.jar c:\temp\apex\utilities

Set the environment variables to allow the APEXExport utility to function, and the settings to tell it how to connect to the relevant database to capture the application or workspace of interest.

set JAVA_HOME="C:\Program Files\Java\jre1.8.0_261"
set APEX_BASE=C:\temp\apex
set CLASSPATH=%APEX_BASE%\utilities\ojdbc8.jar;%APEX_BASE%\utilities

set DB_HOST="ol7_19.localdomain"
set DB_PORT=1521
set DB_SERVICE=pdb1
set DB_USERNAME=MY_APEX_DB_USER
set DB_PASSWORD="MyPassword1"
set APEX_APP_ID=101
set WORKSPACE_ID=2600821031139055

Run the APEXExport utility to extract the SQL representation of the applications or workspace.

Rem Application

%JAVA_HOME%\bin\java oracle.apex.APEXExport ^
  -db %DB_HOST%:%DB_PORT%/%DB_SERVICE% ^
  -user %DB_USERNAME% ^
  -password %DB_PASSWORD% ^
  -workspaceid %WORKSPACE_ID% ^
  -applicationid %APEX_APP_ID% ^
  -expOriginalIds 

Rem All Apps in Workspace

%JAVA_HOME%\bin\java oracle.apex.APEXExport ^
  -db %DB_HOST%:%DB_PORT%/%DB_SERVICE% ^
  -user %DB_USERNAME% ^
  -password %DB_PASSWORD% ^
  -workspaceid %WORKSPACE_ID% ^
  -expOriginalIds 

Rem Workspace

%JAVA_HOME%\bin\java oracle.apex.APEXExport ^
  -db %DB_HOST%:%DB_PORT%/%DB_SERVICE% ^
  -user %DB_USERNAME% ^
  -password %DB_PASSWORD% ^
  -expWorkspace ^
  -workspaceid %WORKSPACE_ID% ^
  -expOriginalIds 

Rem All Workspace

%JAVA_HOME%\bin\java oracle.apex.APEXExport ^
  -db %DB_HOST%:%DB_PORT%/%DB_SERVICE% ^
  -user %DB_USERNAME% ^
  -password %DB_PASSWORD% ^
  -expWorkspace ^
  -expOriginalIds 

Linux Example

Place the software into a directory of your choice. In this example we will use the "/tmp" directory.

Unzip the APEX software and copy the "ojdbc8.jar" file to the utilities directory.

cd /tmp
unzip apex_20.1_en.zip
cp ojdbc8.jar /tmp/apex/utilities

Set the environment variables to allow the APEXExport utility to function, and the settings to tell it how to connect to the relevant database to capture the application or workspace of interest.

JAVA_HOME=/u01/java/latest
APEX_BASE=/tmp/apex
export CLASSPATH=${APEX_BASE}/utilities/ojdbc8.jar:${APEX_BASE}/utilities

DB_HOST="ol7_19.localdomain"
DB_PORT=1521
DB_SERVICE=pdb1
DB_USERNAME=MY_APEX_DB_USER
DB_PASSWORD="MyPassword1"
APEX_APP_ID=101
WORKSPACE_ID=2600821031139055

Run the APEXExport utility to extract the SQL representation of the applications or workspace.

# Application

${JAVA_HOME}/bin/java oracle.apex.APEXExport \
  -db ${DB_HOST}:${DB_PORT}/${DB_SERVICE} \
  -user ${DB_USERNAME} \
  -password ${DB_PASSWORD} \
  -workspaceid ${WORKSPACE_ID} \
  -applicationid ${APEX_APP_ID} \
  -expOriginalIds 

# All Apps in Workspace

${JAVA_HOME}/bin/java oracle.apex.APEXExport \
  -db ${DB_HOST}:${DB_PORT}/${DB_SERVICE} \
  -user ${DB_USERNAME} \
  -password ${DB_PASSWORD} \
  -workspaceid ${WORKSPACE_ID} \
  -expOriginalIds 

# Workspace

${JAVA_HOME}/bin/java oracle.apex.APEXExport \
  -db ${DB_HOST}:${DB_PORT}/${DB_SERVICE} \
  -user ${DB_USERNAME} \
  -password ${DB_PASSWORD} \
  -expWorkspace \
  -workspaceid ${WORKSPACE_ID} \
  -expOriginalIds

# All Workspaces

${JAVA_HOME}/bin/java oracle.apex.APEXExport \
  -db ${DB_HOST}:${DB_PORT}/${DB_SERVICE} \
  -user ${DB_USERNAME} \
  -password ${DB_PASSWORD} \
  -expWorkspace \
  -expOriginalIds

Full Usage Information

The following usage is displayed when the APEXExport utility that ships with version 19.1 is called without parameters.

$ ${JAVA_HOME}/bin/java oracle.apex.APEXExport -h
Usage java oracle.apex.APEXExport [option]...
Available options:
    -h:                    Print this help
    -db:                   Database connect url in JDBC format
    -user:                 Database username
    -password:             Database password
    -applicationid:        ID for application to be exported
    -workspaceid:          Workspace ID for which all applications to be exported or the workspace to be exported
    -instance:             Export all applications
    -expWorkspace:         Export workspace identified by -workspaceid or all workspaces if -workspaceid not specified
    -expMinimal:           Only export workspace definition, users, and groups
    -expFiles:             Export all workspace files identified by -workspaceid
    -skipExportDate:       Exclude export date from application export files
    -expPubReports:        Export all user saved public interactive reports
    -expSavedReports:      Export all user saved interactive reports
    -expIRNotif:           Export all interactive report notifications
    -expTranslations:      Export the translation mappings and all text from the translation repository
    -expFeedback:          Export team development feedback for all workspaces or identified by -workspaceid to development or deployment
    -expTeamdevdata:       Export team development data for all workspaces or identified by -workspaceid
    -deploymentSystem:     Deployment system for exported feedback
    -expFeedbackSince:     Export team development feedback since date in the format YYYYMMDD
    -expOriginalIds:       If specified, the application export will emit ids as they were when the application was imported
    -expNoSubscriptions:   Do not export references to subscribed components
    -expComments:          Export developer comments
    -expSupportingObjects: Pass (Y)es, (N)o or (I)nstall to override the default
    -expACLAssignments:    Export ACL User Role Assignments
    -dir:                  Save all files in the given directory, e.g. -dir some/sub/directory
    -list:                 List all changed applications in the workspace or components in the application
    -changesSince:         Expects date parameter (yyyy-mm-dd). Limit -list values to changes since the given date
    -changesBy:            Expects string parameter. Limit -list values to changes by the given user
    -expComponents:        Export application components. All remaining parameters must be of form TYPE:ID
    -debug:                Print debug output
    -nochecksum:           Overwrite existing files even if the contents have not changed
    -split:                Split applications into multiple files

    Application Example:
       APEXExport -db localhost:1521:ORCL -user scott -password scotts_password -applicationid 31500
    Workspace  Example:
       APEXExport -db localhost:1521:ORCL -user scott -password scotts_password -workspaceid 9999
    Instance Example:
       APEXExport -db localhost:1521:ORCL -user system -password systems_password -instance
    Components Example:
       APEXExport -db localhost:1521:ORCL -user scott -password scotts_password -applicationid 31500 -expComponents PAGE:1 PAGE:2 AUTHORIZATION:12345678
    List Example:
       APEXExport -db localhost:1521:ORCL -user scott -password scotts_password -workspaceid 9999 -list -changesSince 2019-07-29
       APEXExport -db localhost:1521:ORCL -user scott -password scotts_password -applicationid 31500 -list -changesBy EXAMPLE_USER
    Export All Workspaces Example:
       APEXExport -db localhost:1521:ORCL -user system -password systems_password -expWorkspace
    Export Feedback to development environment:
       APEXExport -db localhost:1521:ORCL -user scott -password scotts_password -workspaceid 9999 -expFeedback
    Export Feedback to deployment environment EA2 since 20100308:
       APEXExport -db localhost:1521:ORCL -user scott -password scotts_password -workspaceid 9999 -expFeedback -deploymentSystem EA2 -expFeedbackSince 20100308
$

What About Import?

The APEXExport utility produced regular SQL files, so you don't need a specific tool to import them. You can just use SQL*Plus or SQLcl to load them.

To load a workspace export, you need to connect to a database user with the APEX_ADMINISTRATOR_ROLE role granted to it. To load an application export, you should connect to the workspace database user.

You can also use tools like Liquibase to manage your database, including APEX applications.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.