oracle 检查数据库链接是否实际指向正确的服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10497897/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Check that a DB link is actually pointing to the right server
提问by E. Jaep
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:
我目前正在尝试验证 Oracle db_link 是否实际指向正确的服务器。当我查询 db_links 时,我得到了引用 TNSNames 的 DB_link 的定义:
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
所有者:user1
DB_LINK:DBL_xxx.world
用户名:User2
主机:tnsEntry1
创建时间:03-MAY-12
When I test the DB_link, everything works fine:
当我测试 DB_link 时,一切正常:
select * from dual@"DBL_xxx.world";
DUMMY: X
假人: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.
但是,由于我无权访问服务器,因此无法确保 tns 条目 tnsEntry1 指向正确的服务器。
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?
有没有办法检查远程信息?或者从 sql 查询中检查 tnsnames?
回答by Rene
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'