What is a Multitenant Database?
As of version 12.1, you can design your databases as a multitenant database (CDB). It consists of a container database, 1 root container, one seed pluggable database (seed PDB), and one or more users’ pluggable databases (PDB).
PDB acts as a database that is logically reserved for a user or application. If necessary, non-container databases can be configured in the old method.
The following image shows the container database structure.
- The root container (CDB$ROOT) contains multiple datafiles. These files contain metadata information and common user information provided by Oracle. This information is distributed to all PDBs.
- Seed PDB (PDB$SEED) is a template PDB for the pluggable database(PDB) that users will create. The Seed PDB (PDB $ SEED) ‘s container id is always 2 (two) and is readonly database.
- The PDBs that users create will contain many datafiles. These data files contain application data.
Switch Pluggable Database
When working in container databases, you can switch between databases with the command alter session set container.
1 2 3 | SQL> alter session set container = CDB$ROOT; SQL> alter session set container = CDB$SEED; SQL> alter session set container = USERDB; |
Show Current Container
You can find out the current container with the following commands.
1 2 | SQL> show con_name; SQL> select CDB from v$database; |
While you are in root container, you can query all pluggable databases and containers as follows.
1 2 | SQL> select dbid,con_id,name from v$pdbs; SQL> select name,con_id,dbid from v$containers; |