想在SQLPLUS中一次性运行多个SQL脚本文件 [英] want to run multiple SQL script file in one go with in SQLPLUS
问题描述
我必须一次运行多个 SQL 脚本文件.
就像每次我必须在 SQLPLUS 中编写命令一样
<前>SQL>@d:\a.txtSQL>@d:\a2.txtSQL>@d:\a3.txtSQL>@d:\a4.txt有没有办法把所有文件放在一个文件夹中&一次性运行所有脚本文件,不会丢失任何单个文件,例如 @d:\final.txt
或 @d\final.bat
没有单独的 SQL*Plus 命令可以做到这一点,但您可以创建一个调用所有其他命令的脚本:
将以下内容放入批处理文件
@echo offecho.>"%~dp0all.sql"对于 %%i in ("%~dp0"*.sql) do echo @"%%~fi" >>"%~dp0all.sql"
当您运行该批处理文件时,它将在批处理文件所在的同一目录中创建一个名为 all.sql
的新脚本.它将在批处理文件所在的同一目录中查找扩展名为 .sql
的所有文件.
然后您可以使用 sqlplus user/pwd @all.sql
运行所有脚本(或在创建 all 后扩展批处理文件以调用
脚本)sqlplus
.sql
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
There is no single SQL*Plus command to do that, but you can create a single script that calls all the others:
Put the following into a batch file
@echo off
echo.>"%~dp0all.sql"
for %%i in ("%~dp0"*.sql) do echo @"%%~fi" >> "%~dp0all.sql"
When you run that batch file it will create a new script named all.sql
in the same directory where the batch file is located. It will look for all files with the extension .sql
in the same directory where the batch file is located.
You can then run all scripts by using sqlplus user/pwd @all.sql
(or extend the batch file to call sqlplus
after creating the all.sql
script)
这篇关于想在SQLPLUS中一次性运行多个SQL脚本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!