Want to run multiple SQL script files at a time in SQLPLUS

I need to run several SQL script files at a time.

Like every time I have to write a command in SQLPLUS

SQL> @d: \ a.txt 
SQL> @d: \ a2.txt
SQL> @d: \ a3.txt
SQL> @d: \ a4.txt

is there any way to put the whole file in one folder and run the whole script file at a time without missing a single file like @d:\final.txtor@d\final.bat

+7
source share
8 answers

There is no single SQL * Plus command for this, but you can create one script that calls all the others:

Put the following in a batch file

@echo off
echo.>"%~dp0all.sql"
for %%i in ("%~dp0"*.sql) do echo @"%%~fi" >> "%~dp0all.sql"

, script all.sql , . .sql , .

sqlplus user/pwd @all.sql ( sqlplus all.sql script)

+10

master.sql, .

 c:\direcotory_location\dir *.sql /-t /b >master.sql

open master.sql notepad ++   master.sql

   \n  with \n @

cmd cmd

    C:\root_directory\sqlplus user/password @master.sql

, 30-40 , .

+2

, sql. sql .

cat table_animal.sql > /tmp/temp.sql
cat table_horse.sql >> /tmp/temp.sql
cat table_fish.sql >> /tmp/temp.sql
sqlplus USERNAME/PASSWORD@DOMAIN @/tmp/temp.sql
+1

gnu linux, :

sqlplus USERNAME/PASSWORD@DOMAIN < <(cat a.txt a2.txt a3.txt a4.txt) 
# ... or a for loop on input files, inside the process substitution

.pdc sql-:

-- pdc file
@a.txt;
@a2.txt;
@a3.txt;
@a4.txt;

sql plus:

sqlplus USERNAME/PASSWORD@DOMAIN < my_scripts.pdc
+1

Windows copy/b *.sql + x final.sql

sqlplus user/password @final.sql

+1

, , .

#!/bin/ksh
sqlplus user/password@instance <<EOF
@a.txt
@a1.txt
exit
EOF

For more information about syntax, see. Here document

+1
source

Special thanks to Joseph Torre

sqlplus login/password@server @filename

link link

0
source

Use *.PDCextensions *.PDClike this

File Content install.pdc

whenever sqlerror exit sql.sqlcode

prompt started!

prompt 1.executing script 1
@@install/01.script_1.sql

prompt 2.executing script 2
@@install/02.script_2.sql

prompt 3.executing script 3
@@install/03.script_3.sql

prompt finished!

where @@install/indicates which directory the SQL script is in

0
source

Source: https://habr.com/ru/post/1533675/


All Articles