Reputation: 2153
I am currently trying to validate that an Oracle db_link is actually pointing to the correct server. When I query the db_links I get the definition of the DB_link referencing the TNSNames:
select * from all_db_links;
Gives me the following result:
OWNER: user1
DB_LINK: DBL_xxx.world
Username: User2
Host: tnsEntry1
Created: 03-MAY-12
When I test the DB_link, everything works fine:
select * from dual@"DBL_xxx.world";
DUMMY: X
However, as I do not have access to the server, I cannot make sure that the tns entry tnsEntry1 is pointed to the correct server.
Locally, I can run:
select sys_context ( 'USERENV', 'DB_NAME' ) db_name,
sys_context ( 'USERENV', 'SESSION_USER' ) user_name,
sys_context ( 'USERENV', 'SERVER_HOST' ) db_host
from dual;
I tried to run the same command remotely:
select sys_context ( 'USERENV', 'DB_NAME' ) db_name,
sys_context ( 'USERENV', 'SESSION_USER' ) user_name,
sys_context ( 'USERENV', 'SERVER_HOST' ) db_host
from dual@DBL_xxx.world;
But it returns only local data.
Is there a way to check the remote info? Or check the tnsnames from a sql query?
Upvotes: 2
Views: 15295
Reputation: 10551
This will give you the database name of the database on the other end of the database link:
select property_value
from database_properties@<database_link>
where property_name='GLOBAL_DB_NAME'
Upvotes: 4