通过 SQLPLUS 连接 Oracle 数据库

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

Oracle Database connection via SQLPLUS

oraclesqlplus

提问by Aditya

I am trying to connect to my Oracle database from SQLPlus, but I'm not able to connect.

我正在尝试从 SQLPlus 连接到我的 Oracle 数据库,但无法连接。

I have Oracle client(10g) on my machine. Below are the details through which I am able to connect from my Java application.

我的机器上有 Oracle 客户端(10g)。下面是我能够从我的 Java 应用程序连接的详细信息。

connect('dbi:Oracle://IP/wborcle', 'username', 'pwd'));

What will be the hoststring when connecting via SQLPLUS?

通过 SQLPLUS 连接时主机字符串是什么?

回答by Frank Schmitt

Oracle offers several different methods for lookup up databases when you're trying to connect to them:

当您尝试连接到数据库时,Oracle 提供了几种不同的查找数据库的方法:

  • tnsnames.ora entries
  • LDAP
  • EZConnect
  • ...
  • tnsnames.ora 条目
  • LDAP
  • 易通
  • ...

The most common approach is to put the databases you're connecting to into your tnsnames.ora; usually, your client installation contains an example tnsnames.ora file that you can modify.

最常见的方法是将您要连接的数据库放入您的tnsnames.ora; 通常,您的客户端安装包含一个示例 tnsnames.ora 文件,您可以对其进行修改。

The easiest approach is probably to use EZConnect. An EZConnect string is built like

最简单的方法可能是使用 EZConnect。EZConnect 字符串是这样构建的

<username>/<password>@<hostname>:<port>/SID

<username>/<password>@<hostname>:<port>/SID

so in your case, it (probably) will be something like

所以在你的情况下,它(可能)会像

sqlplus scott/tiger@localhost:1521/wborcle

sqlplus scott/tiger@localhost:1521/wborcle

回答by Mariano Schmands

 sqlplus user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname.network)(Port=1521))(CONNECT_DATA=(SID=remote_SID)))

Maybe, and this might be dependant on the command line environment you're using, you need to quote the string, something like

也许,这可能取决于您使用的命令行环境,您需要引用字符串,例如

sqlplus "user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname.network)(Port=1521))(CONNECT_DATA=(SID=remote_SID)))"

or

或者

 sqlplus 'user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname.network)(Port=1521))(CONNECT_DATA=(SID=remote_SID)))'

回答by Sapam Rajesh Singh

sqlplus username/password@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname)(Port=1521))(CONNECT_DATA=(SID=sidname)))

回答by Steven Moslin

If using the standard client, in order to use ezconnect syntax you may have to set it in your sqlnet.ora file, in the network/admin directory of the client

如果使用标准客户端,为了使用 ezconnect 语法,您可能必须在客户端的 network/admin 目录中的 sqlnet.ora 文件中进行设置

names.directory_path=(tnsnames,ezconnect)

names.directory_path=(tnsnames,ezconnect)