Skip to content

Instantly share code, notes, and snippets.

@divide-by-zero
Created September 1, 2017 08:48
Show Gist options
  • Save divide-by-zero/ca62aeb7570b2d9232cb299f93c789c0 to your computer and use it in GitHub Desktop.
Save divide-by-zero/ca62aeb7570b2d9232cb299f93c789c0 to your computer and use it in GitHub Desktop.
sqlplusで複数SQLを確認しながら順に流し込むbat芸 ref: http://qiita.com/divideby_zero/items/e0432732cbee80463380
hogehoge_alter.sql
hugahuga_insert.sql
mogamoga_update.sql
@echo off
set user=scott
set pass=tiger
set db=orcl
set SQLPLUS=sqlplus %user%/%pass%@%db%
:init
cls
echo userを入力してください enter:%user%
set /p user=
if defined user set user=%user:"=%
echo passwordを入力してください enter:%pass%
set /p pass=
if defined pass set pass=%pass:"=%
echo dbの識別子をどうぞ enter:%db%
set /p db=
if defined db set db=%db:"=%
cls
echo user:%user%
echo password:%pass%
echo db:%db%
echo 以上の設定でよろしいですか? (やりなおし:0)
set /p input=
if defined input set input=%input:"=%
if /i "%input%" == "0" (goto init)
cls
FOR /F "" %%i IN (%1) DO @CALL :SUB %%i
goto Exit
:SUB
set args=%1
echo %args% の流し込み開始します。よろしいですか? (続ける:Enter 中止:0)
set /p input=
if defined input set input=%input:"=%
if /i "%input%" == "0" (goto Exit)
%SQLPLUS% < %args%
EXIT /B
:Exit
pause
exit
dir *.sql /b > list.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment