Is there a way to query the AWS RDS Oracle DB Identifier from SQL?

774 views Asked by At

When you create a DB in RDS you give it a name (specifically "DB Identifier"). Is there a way to query in SQL from a given instance and get that DB Identifier?

2

There are 2 answers

2
Mark Stewart On

Try the SYS_CONTEXT() function -- it can return all sorts of interesting things, including the DB Name:

select sys_context('USERENV', 'DB_NAME') from dual;

See the documentation for all the other values that can be used for the second parameter. This is a funciton that can be called both from a SQL query as above, or from PL/SQL.

0
Brian Fitzgerald On

If you have OEM Agent installed, you can do:

select 
regexp_replace(si.option_setting_value, '\..*', '') db_instance_identifier
from 
rdsadmin.rds_option_settings_info si
where si.option_name = 'OEM_AGENT'
and si.option_setting = 'RDS_PUBLIC_ENDPOINT'