1

我有一个在 oracle 上运行脚本的 BAT 文件:

sqlplus myuser/mypassword@mydatabase @C:\runthisfile.sql

我想将此分发给其他用户(不一定知道如何修改 BAT 文件)。

我希望 dos 提示要求用户输入他们的用户和密码(显然我不想给他们我的连接详细信息)。尝试了所有类型的组合,但所发生的只是我最终得到SQL>......

我难住了!

4

3 回答 3

0

您可以使用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
于 2012-05-21T18:39:39.643 回答
0

关于 SQLPlus 停止,什么都不做:

有时 SQLPlus 以 ... 结束,意思是等待更多的东西。

尝试在 SQL 文件的末尾添加“/”(不带引号)以执行它。

我希望它会有所帮助...

于 2012-07-26T08:25:54.823 回答
0

这是无需手动输入用户名和密码即可打开 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.
于 2017-02-06T07:35:38.520 回答