我有一个在 oracle 上运行脚本的 BAT 文件:
sqlplus myuser/mypassword@mydatabase @C:\runthisfile.sql
我想将此分发给其他用户(不一定知道如何修改 BAT 文件)。
我希望 dos 提示符要求用户输入他们的用户名和密码(显然我不想给他们我的连接详细信息)。尝试过所有类型的组合,但所发生的只是我最终得到了
SQL>.....
。
我被难住了!
您可以使用带有
SET
参数的 /P
命令,以便在批处理文件运行期间提示用户输入文本,例如:
SET /P variable=Please enter text
然后,在按回车键之前,这将用他们输入的任何内容填充
variable
。
@ECHO OFF
SET /P uname=Username:
SET /P pass=password:
这是一个简单的程序,将提示首先输入用户名,然后输入密码。 然后您应该能够将其作为参数传递给 sqlplus:
sqlplus %uname%/%pass%@mydatabase @C:\runthisfile.sql
关于 SQLPlus 停止,不执行任何操作:
有时 SQLPlus 会以 ... 结束,这意味着正在等待更多内容。
尝试在 SQL 文件末尾添加“/”(不带引号)来执行它。
我希望它会有所帮助...
这是打开SQLPLUS的非常简单的代码,无需手动输入用户名和密码。
sqlplus -L 用户名/密码
例如:sqlplus -L Rak4ak@sun64/rk4
为了理解:
sqlplus [ [] [{登录| /nolog}] [] ]
是: [-C ] [-L] [-M ""] [-NOLOGINTIME] [-R ] [-S]
-C <version> Sets the compatibility of affected commands to the
version specified by <version>. The version has
the form "x.y[.z]". For example, -C 10.2.0
-L Attempts to log on just once, instead of
reprompting on error.
-M "<options>" Sets automatic HTML markup of output. The options
have the form:
HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text]
[ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
-NOLOGINTIME Don't display Last Successful Login Time.
-R <level> Sets restricted mode to disable SQL*Plus commands
that interact with the file system. The level can
be 1, 2 or 3. The most restrictive is -R 3 which
disables all user commands interacting with the
file system.
-S Sets silent mode which suppresses the display of
the SQL*Plus banner, prompts, and echoing of
commands.
是:{[/][@] | / } [AS {SYSDBA |系统管理员 |系统管理 |系统备份 |系统开发组 | SYSKM}] [版本=值]
Specifies the database account username, password and connect
identifier for the database connection. Without a connect
identifier, SQL*Plus connects to the default database.
The AS SYSDBA, AS SYSOPER, AS SYSASM, AS SYSBACKUP, AS SYSDG,
and AS SYSKM options are database administration privileges.