Skip to content

Instantly share code, notes, and snippets.

@kazusato
Created July 8, 2018 05:47
Show Gist options
  • Save kazusato/c1cbe21c8d31a1b637b49f10bb54a286 to your computer and use it in GitHub Desktop.
Save kazusato/c1cbe21c8d31a1b637b49f10bb54a286 to your computer and use it in GitHub Desktop.
# Oracle Database 12c CDB/PDB
- CDB = Container Databae
- PDB = Pluggable Database
## tnsnames.ora
```
pdb1=
(description =
(address = (protocol = tcp)(host = localhost)(port = 1521))
(connect_data =
(server = dedicated)
(service_name = pdb1)
)
)
cdb1=
(description =
(address = (protocol = tcp)(host = localhost)(port = 1521))
(connect_data =
(server = dedicated)
(service_name = cdb1)
)
)
```
## startup
```
$ lsnrctl start
$ sqlplus / as sysdba
SQL> startup
SQL> alter pluggable database open;
```
## Connect to PDB with alter session
```
SQL> select pdb_name from dba_pdbs;
SQL> alter session set container = pdb1
```
## Connect to PDB directly
```
$ sqlplus user/pass@pdb1
```
## Creating users on CDB will cause an error.
```
SQL> create user xxx identified by xxx;
create user xxx identified by xxx
*
ERROR at line 1:
ORA-65096: invalid common user or role name
```
## Creating users on PDB will be successful.
SQL> create user xxx identified by xxx;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment