【发布时间】:2020-09-07 09:22:50
【问题描述】:
我在 linux 中创建了一个包含内容的脚本-
sqlplus -silent test/test123@XYZ <<SQL_QUERY
select * from test.persons;
SQL_QUERY
这里-
测试 - 用户名
test@123 - 密码
XYZ - SID 名称
但是当我运行这个我得到错误 -
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
SP2-0306: Invalid option.
谁能帮我解决这个问题? 提前致谢!
【问题讨论】:
-
错误信息似乎很清楚:
test/test123@XYZ不是正确的连接标识符。 -
不,@Barmar 不是这样。与TNS配置有关。
-
Shell 脚本,密码为 sqlplus 和特殊字符 stackoverflow.com/questions/48491926/…
-
嘿@DmitryDemin,谢谢你的帮助。还有一个疑问,我如何将查询的输出存储到某个文件中?
-
"如何将查询的输出存储到某个文件中?"就像你从 shell 脚本中做任何其他事情一样。标准输出重定向。 'somecommand > myfile.txt' --- 这是一份礼物。你真的每个线程只会得到一个问题。
标签: linux bash oracle sh sqlplus