更新时间:2023-12-05 21:36:58
您可以将 exit
这个词通过管道传送到 SQL*Plus 命令行.例如,如果 demo.sql
包含以下内容:
You can pipe the word exit
into the SQL*Plus command line. For example, if demo.sql
consists of this:
prompt This is my demo script
那么你可以这样称呼它:
Then you can call it like this:
echo exit | sqlplus william/w @demo.sql
输出:
Y:\SQL>echo exit | sqlplus william/w @demo.sql
SQL*Plus: Release 12.2.0.1.0 Production on Sun Jan 13 10:47:13 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Last Successful login time: Sun Jan 13 2019 10:46:03 +00:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
This is my demo script
SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Y:\SQL>
或者使用 -s
(静默)选项来抑制横幅等:
Or using the -s
(silent) option to suppress banners etc:
Y:\SQL>echo exit | sqlplus -s william/w @demo.sql
This is my demo script
Y:\SQL>
在 Windows 10 上使用 SQL*Plus 12.2 进行测试.
Tested with SQL*Plus 12.2 on Windows 10.
(来自 https://serverfault.com/q/87035/352734 - 事实证明它适用于两个 Windows和 Linux.)
(From https://serverfault.com/q/87035/352734 - turns out it works in both Windows and Linux.)
您还可以查看避免处理用户名和密码的选项,例如在这里:https://dba.stackexchange.com/a/109170/103604
You could also look at options for avoiding handling usernames and passwords e.g. here: https://dba.stackexchange.com/a/109170/103604