Re: 19c multi-tenant

From: Sayan Malakshinov <xt.and.r_at_gmail.com>
Date: Fri, 12 May 2023 17:22:05 +0100
Message-ID: <CAOVevU6GubNhQ49DtY7qrEjR+ORWCQnEh9sGg5fVOB-e7VEYDQ_at_mail.gmail.com>



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 - 18:22:05 CEST

Original text of this message