oracle Ksh:如何在不使用 tnsnames.ora 的情况下连接到 sqlplus
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8444848/
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
Ksh : How to connect to sqlplus without using tnsnames.ora
提问by stack97
I try to connect to sqlplus from ksh without using tnsnames.ora but that does not work as I would.
我尝试在不使用 tnsnames.ora 的情况下从 ksh 连接到 sqlplus,但这并不能像我一样工作。
Here's what I try :
这是我的尝试:
DBLOGIN="user/password@'(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.17.33)(PORT=1521))(CONNECT_DATA=(SID=MYTESTSID)))'"
SQLPLUS="/etc/sqlplus"
CONNECT=`${SQLPLUS} -S ${DBLOGIN} <<-EOF
SET ECHO OFF;
select count(*) from mytable;
EOF`
echo "$CONNECT"
This should return the number of rows in mytable but that returns nothing so I think that the connection cannot be established...
这应该返回 mytable 中的行数,但没有返回任何内容,所以我认为无法建立连接......
回答by Jean-Philippe Briend
You can also use :
您还可以使用:
sqlplus USER/PASSWORD@//hostName:port/SID
回答by Alessandro Rossi
You can use Easy Connect
您可以使用轻松连接