User Tools

Site Tools


database:oracle:switch-to-pluggable-db-sqlplus

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
database:oracle:sqlplus [2020/04/14 14:29] – external edit 127.0.0.1database:oracle:switch-to-pluggable-db-sqlplus [2023/07/04 19:36] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Switch to a pluggable db (Oracle 12) ====== ====== Switch to a pluggable db (Oracle 12) ======
 +
 +After you are connected with sqlplus to a container database (which is happening by default), run the connect command inside your sqlplus session.
  
 <code sql> <code sql>
-alter session set container=PMJ+conn SYS@PMJ as SYSDBA
 </code> </code>
 +Then you'll be required to enter the SYS password. \\
 +<note>
 +  * If you use a non dba user, don't specify 'as SYSDBA' clause.
 +  * Here PMJ is the name of the pluggable database. 
 +</note>
  
-====== Connect directly to a pluggable db ======+Another way to switch to a PDB is to change the container:
  
-<code> +<code sql
-sqlplus /nolog +alter session set container=PMJ;
-connect SNT@PMJ+
 </code> </code>
  
-====== Format sqlplus output ======+To go back to the CDB container:
  
-<code> +<code sql
-set linesize 2500 +alter session set container=CDB$ROOT; 
-set wrap off +</code>
-set trimout on +
-set trimspool on +
-set long 100000 +
-set pagesize 0 +
-col inmemory_service_name for a10 +
-col table_name for a10 +
-col cluster_name for a20 +
-col cluster_owner for a20 +
-col iot_name for a10 +
-col default_collation for a10 +
-COLUMN first_name FORMAT A10 WORD_WRAP HEADING 'Name' JUSTIFY CENTER+
  
-spool C:\buffer\out.txt 
-@C:\buffer\sql.txt 
-spool off 
-exit 
  
 +====== Connect directly to a pluggable db ======
 +
 +<code>
 +sqlplus /nolog
 +connect SNT@PMJ
 </code> </code>
database/oracle/switch-to-pluggable-db-sqlplus.txt · Last modified: 2023/07/04 19:36 by 127.0.0.1