2012-05-21 135 views
1

我有在Oracle運行的腳本BAT文件:SQLPLUS BAT文件

sqlplus myuser/[email protected] @C:\runthisfile.sql 

我想這個分發給其他用戶(不一定知道如何修改一個BAT文件)。

我想DOS提示要求用戶輸入他們的用戶名和密碼(顯然我不想給他們我的連接細節)。嘗試過所有類型的組合,但所有發生的事情是,我最終與SQL>.....

難倒!

回答

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 
0

用sqlplus不再認爲,無所事事:

有時的SQLPlus光潔度...這意味着正在等待更多的東西。

嘗試在SQL文件的末尾添加「/」(不帶引號)來執行它。

我希望這將有助於...

0

它是沒有手動輸入USENAME和密碼打開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 | 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.