Oracle SQL Developer 如何动态运行sql脚本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13137258/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:12:27  来源:igfitidea点击:

Oracle SQL Developer how to dynamicly run sql scripts

sqloraclebatch-fileoracle-sqldeveloper

提问by Raymond

I have the following challange;

我有以下挑战;

I would like to execute a batch of *.sql files on one database. The sql files are assumed to be named in ascending order of their execution sequence. So the main sql script should do a 'dir /s *.sql', then start each of the found scripts in order.

我想在一个数据库上执行一批 *.sql 文件。假定 sql 文件按其执行顺序的升序命名。所以主sql脚本应该做一个'dir /s *.sql',然后按顺序启动每个找到的脚本。

Is this possible ?

这可能吗 ?

Below is something I found for SQL Server, but I want something similar for Oracle SQL Developer.

下面是我为 SQL Server 找到的东西,但我想要为 Oracle SQL Developer 找到类似的东西。

http://pradeep1210.wordpress.com/2012/03/15/executing-a-set-of-sql-script-files-sql-on-a-group-of-sql-server-databases/

http://pradeep1210.wordpress.com/2012/03/15/executing-a-set-of-sql-script-files-sql-on-a-group-of-sql-server-databases/

Thanks in advance.

提前致谢。

Raymond

雷蒙德

回答by Gaurav Soni

  1. Create a folder for eg:Batch_Filesin you local machine ,which will contain all the sql script that you want to execute ,
  2. Then open you sql developer.Create a file called batch.sqlin your Batch_Files folder .
  3. In Batch.sqladd the sql files that you want to execute in sequence.

    @file1.sql

    @file2.sql :

    :

    @fileN.sql

  1. 创建一个文件夹,例如:Batch_Files在您的本地机器中,其中将包含您要执行的所有 sql 脚本,
  2. 然后打开你。在你的 Batch_Files 文件夹中sql developer创建一个文件batch.sql
  3. Batch.sql添加SQL文件,您希望按顺序执行。

    @file1.sql

    @file2.sql :

    @fileN.sql

These files contains the code that you need to run in sequence .This is a very basic example.You can do various changes according to your need ,you can add anonymous block to print something after execution of files .I have not tested this is SQL-DEVELOPER,but i think this will surely work for you .

这些文件包含你需要按顺序运行的代码。这是一个非常基本的例子。你可以根据你的需要做各种改变,你可以在文件执行后添加匿名块来打印一些东西。我没有测试过这个SQL-DEVELOPER,但我认为这肯定对你有用。