查找 Oracle 数据库的服务器名称

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2366962/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 02:26:51  来源:igfitidea点击:

Find the server name for an Oracle database

oracle

提问by darreljnz

Is there a way of finding the name of the server an Oracle database is hosted on?

有没有办法找到托管 Oracle 数据库的服务器的名称?

回答by Gary Myers

If you don't have access to the v$ views (as suggested by Quassnoi) there are two alternatives

如果您无权访问 v$ 视图(如 Quassnoi 所建议),则有两种选择

select utl_inaddr.get_host_name from dual

and

select sys_context('USERENV','SERVER_HOST') from dual

Personally I'd tend towards the last as it doesn't require any grants/privileges which makes it easier from stored procedures.

我个人倾向于最后一个,因为它不需要任何授权/特权,这使得存储过程更容易。

回答by Quassnoi

SELECT  host_name
FROM    v$instance

回答by Sandra

The query below demonstrates use of the package and some of the information you can get.

下面的查询演示了包的使用以及您可以获得的一些信息。

select sys_context ( 'USERENV', 'DB_NAME' ) db_name,
sys_context ( 'USERENV', 'SESSION_USER' ) user_name,
sys_context ( 'USERENV', 'SERVER_HOST' ) db_host,
sys_context ( 'USERENV', 'HOST' ) user_host
from dual

NOTE: The parameter ‘SERVER_HOST' is available in 10G only.

注意:参数“SERVER_HOST”仅在 10G 中可用。

Any Oracle User that can connect to the database can run a query against “dual”. No special permissions are required and SYS_CONTEXT provides a greater range of application-specific information than “sys.v$instance”.

任何可以连接到数据库的 Oracle 用户都可以针对“双重”运行查询。不需要特殊权限,SYS_CONTEXT 提供比“sys.v$instance”更大范围的特定于应用程序的信息。

回答by sandatomo

I use this query in order to retrieve the server name of my Oracle database.

我使用这个查询来检索我的 Oracle 数据库的服务器名称。

SELECT program FROM v$session WHERE program LIKE '%(PMON)%';