问题描述
我已经在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 - username
test@123 - password
XYZ - SID Name
我猜您实际上是在尝试运行:
sqlplus -silent test/test@123@XYZ
这就是为什么SQL * Plus会因为2个“ @”而抱怨的原因。
请尝试将密码放在双引号中以避免这种情况。更好的方法是将密码放在连接钱包中,因此永远不会在脚本中进行编码。请参阅这篇文章,了解如何操作
https://connor-mcdonald.com/2015/09/21/connection-shortcuts-with-a-wallet/