SQLPLUS BAT文件

时间:2012-05-21 16:05:18

标签: batch-file sqlplus

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

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

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

我希望dos提示要求用户输入他们的用户名和密码(显然我不想向他们提供我的连接详情)。尝试了所有类型的组合,但所有发生的事情都是SQL>.....

难倒!

3 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

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

有时候SQLPlus会以...结束,这意味着等待更多的东西。

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

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

答案 2 :(得分:0)

这是打开SQLPLUS而不手动输入用户名和密码的非常简单的代码。

sqlplus -L用户名/密码

例如: sqlplus -L Rak4ak @ sun64 / rk4

了解:

sqlplus [[] [{logon | / 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 | SYSOPER | SYSASM | SYSBACKUP | SYSDG | SYSKM}] [EDITION = value]

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.