Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

want to run multiple SQL script file in one go with in SQLPLUS

Tags:

sql

sqlplus

I have to run multiple SQL script file in one go.

Like every time i have to write command in SQLPLUS

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

is there any way put all file in one folder & run all script file in one go without missing any single file like @d:\final.txt or @d\final.bat

like image 370
rahul jain Avatar asked Mar 27 '14 07:03

rahul jain


People also ask

How do I run a SQL script in Sqlplus?

Answer: To execute a script file in SQLPlus, type @ and then the file name. The above command assumes that the file is in the current directory. (ie: the current directory is usually the directory that you were located in before you launched SQLPlus.) This command would run a script file called script.

Can two statements run in one SQL script?

You can include multiple SQL statements on the SQL query panel. The exceptions are CALL and CREATE PROCEDURE statements. These statements must be used alone in a query.


1 Answers

Some tricks and command can help you to generate master.sql file and you can run from that location.

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

Go to the parent directory open master.sql open using notepad++ remove master.sql line and use regular expression to replace

   \n  with \n @

go to cmd From cmd

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

I find this process very convenient if i have 30 to 40 scripts placed in a single directory.

like image 156
Manoj Avatar answered Sep 24 '22 21:09

Manoj