Oracle SQL Developer中如何动态地运行SQL脚本 [英] Oracle SQL Developer how to dynamicly run sql scripts

查看:1087
本文介绍了Oracle SQL Developer中如何动态地运行SQL脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下challange;

我想在执行一个数据库一批* .sql文件。假设SQL文件按升序它们的执行顺序的顺序来命名。因此,主SQL脚本应该做一个DIR / S * .SQL,则为了各自的启动脚本中发现的。

这可能吗?

下面是我发现的SQL Server,但我要为Oracle SQL Developer中类似的东西。

<一个href=\"http://pradeep1210.word$p$pss.com/2012/03/15/executing-a-set-of-sql-script-files-sql-on-a-group-of-sql-server-databases/\" rel=\"nofollow\">http://pradeep1210.word$p$pss.com/2012/03/15/executing-a-set-of-sql-script-files-sql-on-a-group-of-sql-server-databases/

先谢谢了。

雷蒙德


解决方案

  1. 创建用于例如,一个文件夹: Batch_Files 在你的本地计算机,其中将包含你想要执行的所有SQL脚本,

  2. 然后打开 SQL Developer的 .Create一个名为 batch.sql 在Batch_Files文件夹中。

  3. Batch.sql 添加您希望按顺序执行SQL文件。

    @ file1.sql

    @ file2.sql
      

    @ fileN.sql


这些文件包含code,你需要按顺序运行。这是一个非常基本的example.You可以做各种变化根据您的需要,您可以添加匿名块的文件执行后打印的东西。我还没有测试,这是 SQL开发者,但我认为这必将为你工作。

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.

Is this possible ?

Below is something I found for SQL Server, but I want something similar for 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/

Thanks in advance.

Raymond

解决方案

  1. Create a folder for eg:Batch_Files in 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.sql in your Batch_Files folder .
  3. In Batch.sql add the sql files that you want to execute in sequence.

    @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 .

这篇关于Oracle SQL Developer中如何动态地运行SQL脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆