如何查找 Oracle 服务名称

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

How to find Oracle Service Name

oracle

提问by Anders Jakobsen

I have an Oracle database on my network which I am able to connect to with Oracle SQL Developer, using hostname, port, username, password and the SID.

我的网络上有一个 Oracle 数据库,我可以使用主机名、端口、用户名、密码和 SID 连接到 Oracle SQL Developer。

I need to connect another application (Quantum Gis), however it uses the Service Name instead of the SID.

我需要连接另一个应用程序 (Quantum Gis),但它使用服务名称而不是 SID。

Is there any way for me to determine the SERVICE_NAME of the database when I am connected in SQL Developer via the SID?

当我通过 SID 在 SQL Developer 中连接时,有什么方法可以确定数据库的 SERVICE_NAME 吗?

I do not have access to the server and have no local tnsnames.ora or similar.

我无权访问服务器,也没有本地 tnsnames.ora 或类似文件。

采纳答案by Marmite Bomber

Overview of the services used by all sessions provides the distionary view v$session(or gv$sessionfor RAC databases) in the column SERVICE_NAME.

所有会话使用的服务概览在列中提供了字典视图v$session(或gv$session用于 RAC 数据库)SERVICE_NAME

To limit the information to the connected session use the SID from the view V$MYSTAT:

要将信息限制为连接的会话,请使用视图中的 SID V$MYSTAT

select SERVICE_NAME from gv$session where sid in (
select sid from V$MYSTAT)

If the name is SYS$USERSthe session is connected to a defaultservice, i.e. in the connection string no explicit service_name was specified.

如果名称是SYS$USERS会话连接到默认服务,即在连接字符串中未指定明确的 service_name。

To see what services are availablein the database use following queries:

要查看数据库中可用的服务,使用以下查询:

select name from V$SERVICES;
select name from V$ACTIVE_SERVICES;

回答by Goufalite

Found here, no DBA : Checking oracle sid and database name

在这里找到,没有 DBA : Checking oracle sid and database name

select * from global_name;

回答by user674669

Connect to the server as "system" using SID. Execute this query:

使用 SID 作为“系统”连接到服务器。执行此查询:

select value from v$parameter where name like '%service_name%';

It worked for me.

它对我有用。

回答by Dhyan Mohandas

Check the service name of a database by

通过以下方式检查数据库的服务名称

sql> show parameter service;

sql> 显示参数服务;

回答by Carl Bosch

Thanks to this thread (https://community.oracle.com/thread/473276)

感谢这个线程(https://community.oracle.com/thread/473276

select sys_context('userenv','service_name') from dual;

select sys_context('userenv','service_name') from dual;

It can be executed with a regular user account, no need for sysdba rights

可以使用普通用户帐户执行,无需 sysdba 权限

回答by Moiz Sajid

Connect to the database with the "system" user, and execute the following command:

以“system”用户连接数据库,执行如下命令:

show parameter service_name 

回答by Rahul Balu

TO FIND ORACLE_SID USE $. oraenv

查找 ORACLE_SID 使用 $. 环境

回答by Andrea Diggelmann

With SQL Developer you should also find it without writing any query. Right click on your Connection/Propriety.

使用 SQL Developer,您还应该在不编写任何查询的情况下找到它。右键单击您的连接/属性。

You should see the name on the left under something like "connection details" and should look like "Connectionname@servicename", or on the right, under the connection's details.

您应该会在左侧的“连接详细信息”下看到名称,看起来应该像“Connectionname@servicename”,或者在右侧,在连接的详细信息下。