Database Reference
In-Depth Information
Connecting to a PDB Using the SQL*Plus ALTE R S E S S I O N
Command
In addition to using the CONNECT SQL*Plus command, you can alter the session to switch to a
different current database, whether it's the CDB or any other PDB that you have access to in
the CDB. To switch from the current CDB to a PDB, use the ALTER SESSION command:
SQL> connect testpdb/password@pdb1
Connected.
SQL> ALTER SESSION SET CONTAINER=CDB$ROOT;
ERROR:
ORA-01031: insufficient privileges
SQL> SHOW USER
USER is "TESTPDB"
SQL>
As you can see, the locally created user testpdb does not have sufficient privileges to con-
nect to CDB$ROOT . To connect to the CDB$ROOT , you must connect as a common user, such as
SYS or SYSTEM , for example. Connect as SYS and then switch from the current CDB to a PDB,
using the ALTER SESSION command:
SQL> CONNECT SYS/SYSTEM@CONT AS SYSDBA
Connected.
SQL> SHOW CON_NAME
CON_NAME
------------------
CDB$ROOT
SQL>
SQL> ALTER SESSION SET CONTAINER = pdb1;
Session altered.
SQL> SHOW CON_NAME
CON_NAME
------------------
PDB1
While you're here, create a new tablespace specifically for the PDB1 database, and make
it the default tablespace for user testpdb . By switching from the CDB$ROOT to PDB1 , you've
Search WWH ::




Custom Search