Sub topic 2
Connecting to the CDB and the FREEPDB1 Pluggable Database
This chapter assumes you can run a container with Docker or Podman, use SQL*Plus or SQLcl from a terminal, and know that SYS and ADMIN are privileged accounts.
Connecting to the CDB and FREEPDB1
Oracle Database 26ai Free runs as a container database (CDB). Application data lives in a pluggable database (PDB), here named FREEPDB1. Connect to the PDB service for practice work, not to the CDB root.
Start the container and wait for the ready message:
docker run -d --name oracle-free -p 1521:1521 \
-e ORACLE_PWD='ChangeMe_123' \
container-registry.oracle.com/database/free:latest
docker logs -f oracle-freeWait for the line DATABASE IS READY TO USE! before connecting. Then connect to the PDB service:
sqlplus sys/ChangeMe_123@localhost:1521/FREEPDB1 as sysdbaConfirm you are in the PDB:
SELECT sys_context('USERENV', 'CON_NAME') AS container_name FROM dual;The result should be FREEPDB1.
Creating an Always Free Autonomous Database
In the Oracle Cloud Console, create an Autonomous Database and select the Always Free option. Choose a workload type, set the ADMIN password, and set network access. Provisioning takes a few minutes.
Connecting with Database Actions, TLS and Wallets
Database Actions is the browser tool for the instance. Open it from the database details page and sign in as ADMIN to run SQL in a worksheet.
For SQL*Plus, SQLcl, or application drivers, download the client credentials wallet from the database connection page. The wallet holds the certificates used for mutual TLS (mTLS). Unzip it, point TNS_ADMIN at the folder, and connect with one of the service names in tnsnames.ora:
export TNS_ADMIN=/path/to/wallet
sqlplus app_user@myadb_lowServices ending in _low, _medium, and _high differ in resource level and concurrency.
> Treat the wallet as a secret. Anyone who has it and a valid password can connect.
Some instances also allow TLS connections without a wallet. Check the connection settings before you download one.
Creating a Development User
Do not practice as SYS or ADMIN. In FREEPDB1, connect as SYS with sysdba and run:
CREATE USER app_user IDENTIFIED BY "ChangeMe_123" QUOTA UNLIMITED ON users;
GRANT DB_DEVELOPER_ROLE TO app_user;On Autonomous Database, run the same pattern as ADMIN, but use the DATA tablespace in place of users.
Test the account by connecting as app_user and running SELECT user FROM dual;.
Exercise
Why should practice tables go in FREEPDB1 instead of the CDB root, and what does sys_context('USERENV', 'CON_NAME') confirm?
Show answer
FREEPDB1 is the pluggable database that holds application data, and the CDB root is reserved for Oracle's own components. The query returns the container name your session is in, so a result of FREEPDB1 confirms you are in the right place.