Databases Reference
In-Depth Information
Showing the Currently Connected Pluggable Database
From SQL*Plus there are a couple of easy techniques for displaying the name of the pluggable database that you're
currently connected to. This example uses the SHOW command to display the container ID, the name, and the user:
SQL> show con_id con_name user
Here is some sample output:
CON_ID
------------------------------
3
CON_NAME
------------------------------
SALESPDB
USER is "SYS"
You can also display the same information via an SQL query:
SELECT SYS_CONTEXT('USERENV', 'CON_ID') AS con_id,
SYS_CONTEXT('USERENV', 'CON_NAME') AS cur_container,
SYS_CONTEXT('USERENV', 'SESSION_USER') AS cur_user
FROM DUAL;
Here is some sample output:
CON_ID CUR_CONTAINER CUR_USER
---------- --------------- ----------
3 SALESPDB SYS
Keep in mind that the SYS_CONTEXT function can be used to display other useful information, such as the
SERVICE_NAME , DB_UNIQUE_NAME , INSTANCE_NAME , and SERVER_HOST ; for example,
SELECT
SYS_CONTEXT('USERENV', 'SERVICE_NAME') as service_name,
SYS_CONTEXT('USERENV', 'DB_UNIQUE_NAME') as db_unique_name,
SYS_CONTEXT('USERENV', 'INSTANCE_NAME') as instance_name,
SYS_CONTEXT('USERENV', 'SERVER_HOST') as server_host
from dual;
Starting/Stopping a Pluggable Database
When you start/stop a pluggable database, you aren't starting/stopping an instance. Rather, you are making
the pluggable database either available or unavailable, open or closed. You can change the open mode of a
pluggable database from either a connection to the root container as SYS or a direct connection to the pluggable
database as SYS .
 
Search WWH ::




Custom Search