CONNECT 应该在 SQL*PLUS 脚本中工作吗?
我想从 cron 作业运行 sqlplus 脚本。
添加一行: ,
CONNECT "myuser/mypass@mydb"
我想我可以在脚本中
sqlplus @myscript
然后使用以下命令执行它:但是,当我这样做时,我得到:
SP2-0306: Invalid Option
SP3-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
我是否误解了 connect 命令的用法?
I'd like to run a sqlplus script from a cron job.
I thought I could put a line like:
CONNECT "myuser/mypass@mydb"
within the script and then just execute it with:
sqlplus @myscript
However, when I do so, I get:
SP2-0306: Invalid Option
SP3-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
Am I misunderstanding the usage of the connect command?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在
SQL*Plus
内运行CONNECT
时,请删除引号:如果您将凭据作为参数传递给
sqlplus
,则需要双引号:,如果连接标识符中有空格或使用诸如
AS SYSDBA
之类的附加选项,则 shell 将myuser/mypass@mydb
解析为单个参数。When running
CONNECT
insideSQL*Plus
, remove the quotes:They double quotes are required if you are passing the credentials as an argument to
sqlplus
:, for the shell to parse
myuser/mypass@mydb
as a single argument if you have spaces in your connection identifier or use additional options likeAS SYSDBA
.使用 /NOLOG 选项。
Use the /NOLOG option.
Oracle 11gR2
我通过最初作为 JOHN 连接的 SQL*Plus 运行了一个 .sql 文件。在文件中,我以 SYS 身份连接,然后运行 GRANT。请参阅下面的 .sql 文件内容:
connect sys/password as sysdba
GRANT EXECUTE ON DBMS_CRYPTO TO JOHN;
连接约翰/能源部
注意:顺便说一句,我不建议将系统/密码保存在文本文件中。
华泰
Oracle 11gR2
I ran a .sql file via SQL*Plus connected initially as JOHN. Within the file I connect as SYS and then run a GRANT. See .sql file contents below:
connect sys/password as sysdba
GRANT EXECUTE ON DBMS_CRYPTO TO JOHN;
connect JOHN/DOE
NOTE: I don't recommend keeping the sys/password in a text file btw.
HTH