Update: this is still valid for ORDS-versions up to 21.x. With ORDS 22.x, this got a bit easier. I created a newer cookbook under Clone a pluggable Database with APEX and connect to ORDS 22.x.
---8<-----------------------------------------------------------------------------
Sometimes I quickly need another test/dev environment for Apex. There are several ways to get one: snapshot or clone the VM, create one with Liquibase or clone the PDB and link the ORDS to it as described below. This is meant as a short cookbook, find more detailed information on the sites from Jeff Smith or Oracle-Base.
Start by connecting to your CDB and create a clone of the PDB where Apex is installed.
create pluggable database orclpdb2 from orclpdb file_name_convert = ('/orclpdb/', '/orclpdb2/'); alter pluggable database orclpdb2 open; sho pdbs alter session set container=orclpdb2; select * from apex_release;
Now all we have to do is to tell ORDS about the 2nd PDB. First we need to configure the DB with
java -jar ords.war setup --database orclpdb2
java -jar ords.war map-url --type base-path /orclpdb2 orclpdb2
And that is all, restart your ORDS
ORDS should log the new connection. Open the new URL with your browser, in my case:
vm:8080/ords/orclpdb2/apex
The difference between the first and all other databases for an ORDS is, that the first one is always accessible without an additional base-path (like vm:8080/ords/apex) whereas the others always need that base-path. If you want a base-path also for the first database, see this posting from Jeff Smith.
Apex for the second PDB should be available under that new URL.And there is also a second Database Actions / SQLDeveloper Web under that new URL pattern.
This is done in less than 5 minutes and depending on your environment, this might be faster than cloning the complete VM. And dropping it only takes seconds, what also might be faster than restoring a snapshot of your VM.