1. Connect to the server and start the database:
sqlplus / as sysdba
startup;
2. The server side connects and closes the database:
sqlplus / as sysdba
shutdown immediate;
3. Connect to the specified database
Sqlplus username/passwd@tnsname
4. View the currently connected database or container
show con_name
5. View all current containers
Select * from v$containers;
6. View all current pdb
Select * from v$pdbs;
7. Switch connections to different containers
Alter session set container=pdb1;
Alter session set container=cdb$root;
Sqlplus username/passwd@tnsname
8. open pdb
Alter pluggable database pdb1 open;
Alter pluggable database all open;
9. close pdb
Alter pluggable database pdb1 close;
Alter pluggable database all close;
10. Create a user
--global user
Alter session set container=cdb$root;
Create user c##username identified by test default tablespace userstemporary tablespace temp;
Grant connect to c##test;
--local user
Alter session set container=pdb1;
Create user test identified by test default tablespace users temporarytablespace temp;
Grant connect to test;
11. Modify parameters
--Modify the current container parameters
Alter system set para_name=para_value;
Alter system set para_name=para_value container=current;
--Modify all container parameters
Alter system set para_name=para_value container=all;
--View parameters that can be modified by pdb
Select name,value,ispdb_modifiable from v$system_parameter
Where ispdb_modifiable='TRUE';
12. Listener and tnsname configuration example
--listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ora12c)
(ORACLE_HOME =/home/oracle/product/12.1.0/db1)
(SID_NAME = ora12c)
)
(SID_DESC=
(GLOBAL_DBNAME = pdb1)
(ORACLE_HOME =/home/oracle/product/12.1.0/db1)
(SID_NAME=ora12c))
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL =TCP)(HOST = localhost)(PORT = 1521))
)
ADR_BASE_LISTENER = /home/oracle
--tnsnames.ora
ORA12C1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL =TCP)(HOST = 192.168.1.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ora12c)
)
)
PDB1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL =TCP)(HOST = 192.168.1.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = pdb1)
)
)