CONNECT 应该在 SQL*PLUS 脚本中工作吗?

发布于 2024-08-19 16:01:54 字数 354 浏览 1 评论 0原文

我想从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

简单 2024-08-26 16:01:54

SQL*Plus 内运行 CONNECT 时,请删除引号:

CONNECT myuser/mypass@mydb

如果您将凭据作为参数传递给 sqlplus,则需要双引号:

sqlplus "myuser/mypass@mydb"

,如果连接标识符中有空格或使用诸如 AS SYSDBA 之类的附加选项,则 shell 将 myuser/mypass@mydb 解析为单个参数。

When running CONNECT inside SQL*Plus, remove the quotes:

CONNECT myuser/mypass@mydb

They double quotes are required if you are passing the credentials as an argument to sqlplus:

sqlplus "myuser/mypass@mydb"

, for the shell to parse myuser/mypass@mydb as a single argument if you have spaces in your connection identifier or use additional options like AS SYSDBA.

纵性 2024-08-26 16:01:54

使用 /NOLOG 选项。

sqlplus /nolog @myscript

Use the /NOLOG option.

sqlplus /nolog @myscript
眼睛会笑 2024-08-26 16:01:54

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文