Re: 19c multi-tenant

From: Sayan Malakshinov <xt.and.r_at_gmail.com>
Date: Fri, 12 May 2023 18:24:43 +0100
Message-ID: <CAOVevU4gJsiDcCqNEOW2aGQ99Cxf=e6L04yw-S6BX_F4XY8ZSQ_at_mail.gmail.com>



Amir,

Yes, since PDB name is a different thing. Moreover, you can have problems in case of the same pdb name on two different CDBs:
https://oracle-base.com/articles/12c/multitenant-pluggable-database-names-12cr1

Best regards,
Sayan Malakshinov
Oracle performance tuning expert
Oracle Database Developer Choice Award winner Oracle ACE
http://orasql.org

On Fri, 12 May 2023, 18:01 Amir Hameed, <axhameed_at_yahoo.com> wrote:

> Thank you Sayan!
>
> Does it mean that v$database will always provide DB_NAME and
> DB_UNIQUE_NAME of the CDB even if the statement is run from a PDB?
>
> Thanks,
> Amir
>
>
> On Friday, May 12, 2023 at 12:23:06 PM EDT, Sayan Malakshinov <
> xt.and.r_at_gmail.com> wrote:
>
>
> Hi Amir,
>
> You can also get it from v$pdbs:
> select name from v$pdbs;
>
> And you can dynamically get your current pdb name in case of CDB='YES':
>
> SELECT
> db.name as db_name
> ,db.db_unique_name
> ,pdb.name as pdb_name
> ,case db.cdb
> when 'YES' then pdb.name
> else db.name
> end as c_name
> FROM v$database db,
> v$pdbs pdb;
>
>
> On Fri, May 12, 2023 at 4:33 PM Hameed Amir <dmarc-noreply_at_freelists.org>
> wrote:
>
> Hi folks,
>
> In a multitenant environment, does the following query always return
> values from the CDB even if run from a PDB?
>
>
>
> SELECT db_name, db_unique_name FROM v$database ;
>
>
>
> We are upgrading our Oracle EBS database from 11g to 19c and at any place
> where the custom code is getting the DB name using the query “SELECT name
> INTO l_dbname FROM v$database”, it is failing because the query is
> returning the CDB name instead of the PDB’s.
>
>
>
> - I am assuming that this is the expected behavior where the DB_NAME
> and UNIQUE_DB_NAME when queries from V$DATABASE from any PDB always return
> values from the CDB.
> - Is the best way to get the PDB name to use the following query?
> SELECT SYS_CONTEXT(‘userenv’,’db_name’) FROM dual ;
>
>
>
>
>
> Thank you,
>
> Amir
>
>
>
> --
> Best regards,
> Sayan Malakshinov
> Oracle performance tuning engineer
> Oracle ACE
> http://orasql.org
>

--
http://www.freelists.org/webpage/oracle-l
Received on Fri May 12 2023 - 19:24:43 CEST

Original text of this message