# Oracle Database Multitenant – DMK features

## DMK configuration and variables of pluggabable database(s)

### Configuration

:information\_source: There is no Oracle configuration file or OS-process to identify PDBs, so you can only know which PDBs exist with a select in the CDB.

DMK Release 1: ~~In this release the pluggable databases are added as a comma-separated list after the start-flag of the /etc/oratab entry~~

DMK Release 2:

For each pluggable database an (empty) file will be created below `$DMK_ORA_ADMIN_SID/dmk/pdbs`; That is automatically done

* the 1st time the database (cdb) is detected (and is open)
* each time "[status.pl](http://status.pl) inst" (alias istat) is called
* If DMK is sourced for the SID and the variable DMK\_NO\_PDB\_CHECK is NOT set or 0.

The PDB file `$DMK_ORA_ADMIN_SID/dmk/pdbs/PDBNAME` (initially created empty) can be used for PDB specific settings, e.g. for PDB1 of instance DBICDB. The format is the same as dmk.conf or $ORACLE\_SID.conf

```
[DBICDB.PDB1]
var::TESTVARPDB01::=::nowarn::TestValue::
```

If DMK detects a new PDB, it creates the empty configuration file, or if it detects the removal of a PDB, it deletes the configuration file described above.\
Because "`status.pl inst`" (alias `istat`) is *executed* and *not sourced*, it only can update the configuration files, but not the environment. To get the new PDB alias, you have to re-source DMK, The status.pl utility gives you the information to do so:

```
INFO: New PDB found: 'WEBP'
INFO: Old PDB deleted: 'WEBT'

**************************************************************
WARNING: Changes in PDBs detected. Re-source your environment!
**************************************************************
```

### Variables

#### `DMK_PDBS_$ORACLE_SID`

For each container database instance this variable is generated with a space-separated list of the user PDBs (not PDB$SEED and CDB$ROOT), e.g. "`PDB1 PDB2 PDB3`".\
If the variable is empty, then it is a container database without a PDB.

#### `DMK_SID_PDB_NAME`, `DMK_SID_PDB`

`DMK_SID_PDB_NAME` contains the name of the current PDB or `CDB$ROOT`.\
`DMK_SID_PDB` contains the string to be printed in the prompt, e.g. ' `(PDB1)`'.

#### `DMK_NO_SID_PDB_ALIASES`

For each known PDB an alias SID.PDB will be generated. If this variable is set to 1, the aliases will not be generated.

#### `DMK_PDB_CHECK`

To check if there are new PDBs or if PDBs are deleted, a login to the container database is required. To reduce the overhead, DMK will per default only check for PDB changes if the instance status is shown (`. dmk.sh -s SID` (alias SID) -or- `status.pl i` (alias istat).

If you have a very agile environment with often add/remove of PDBs to an existing CDB, then it is recommended to set this variable to 1.

```
#dmk.conf.local
var::DMK_NO_PDB_CHECK::=::nowarn::1::
```

:information\_source: If you call the instance-status (istat), the PDB files will be updated, but aliases and variables are not yet set because status.pl is executed and not sourced. Re-source dmk, then the environment is updated.

#### ~~DMK\_ORA12C\_PDBS~~

Do *NOT* use this variable. It is obsolete, the name is misleading and it will be removed in a future release. Use `DMK_PDBS_$ORACLE_SID` instead.

## Oracle Multitenant Database core integration

### List pluggable databases & setting environment

The listing of the pluggable databases of the current SID have been added to the database status script (alias istat). Alternatively you can also use the “lspdb” alias.

Example: Setting the ORACLE\_SID for database DBICDB:

<figure><img src="https://3382315087-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPtQvF2ryopbZznR9blJe%2Fuploads%2Fgit-blob-98125928b4e96f8369358c69657d5c2194f40f2a%2Fimage%20(11).png?alt=media" alt=""><figcaption></figcaption></figure>

Example: Output of the command lspdb

```
oracle@vmoel58:/home/oracle/ [CDBUTF8 (CDB$ROOT)] lspdb
******** dbi services Ltd. ********
DBICDB -- Pluggable database(s)
-----------------------------------
PDB name : Open Mode
-----------------------------------
LMA : READ WRITE
PDB$SEED : READ ONLY
PDB1 : READ WRITE
***********************************
```

To list all (known) PDBs, use the lspdbs.pl script (alias lspdbs). It is based on the DMK\_PDBS\_\<SID> variables.

```
sid:      pdb's
--------  -----
DB1830:   PDB
DB18SE:
DB1970:   PDB01 PDB02
DB2100A:  DB2100PDB1
```

### Pluggable database administration

This feature allows performing the “alter session set container” within sqlplus automatically, using an operating system alias. The current container name is displayed within the default prompt. This works through an SQL-statement, defined by the variable DMK\_EXEC\_SQL\_SCRIPT in DMK.conf.default. If you specify it, DMK will append the statement to your script by creating a temporary execution copy.

The PDBs are defined as a (empty) file in `$DMK_ORA_ADMIN_SID/dmk/pdbs/`; Optionally you can define PDB-specific variables and aliases in it.

Example of setting the environment for a pluggable database:

```
oracle@vmoel58:/u01/app/oracle/local/dmk/ [CDBUTF8 (CDB$ROOT)] pdb1
oracle@vmoel58:/u01/app/oracle/local/dmk/ [CDBUTF8(PDB1)] sqh
SQL*Plus: Release 19.12.0.0 Production on Sun Jun 30 10:31:00 2021
Copyright (c) 2021, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.12.0.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing
options
SQL> show con_name
CON_NAME
------------------------------
PDB1
```

New with Release 2:

Instead of setting first the environment for the CDB, then the environment for the PDB (which still works), you can directly set a pdb environment with the alias \<CDB>.\<PDB>, in the example above with

```
CDBUTF8.PDB1
cdbutf8.pdb1
```
