If we have databases with the same PDB name, running on the same server under different CDB, this creates a namespace clash for our normal tnsnames connection as below:
PDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb)))
To differentiate between PDB’s we must update the tns string to include the (INSTANCE_NAME = <instance>) as below
PDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb)(INSTANCE_NAME = ORCL)
)
)
PDB2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb) (INSTANCE_NAME = ORCL2)
)
)