Search code examples
sqloracle-databaseoracle12creleaseproduction-environment

How to create one common sql file to execute all other related sql file in release


Suppose, We have three files in our release package.

  1. insertTable.sql contains all insert statement for various database table
  2. deleteTable.sql contains all delete statement for various database table
  3. updateTable.sql contains all update statement for various database table

Now, I want to create one single file that executes all these files. So users need not to execute all file statements one by one.

Database Environment - Oracle 12c


Solution

  • Not too complicated; name all those scripts in the "master" script, with their names preceded by the @ sign.

    For example, I have created 3 scripts: a.sql, b.sql and c.sql. All of them look similar, i.e. they just display where I am:

    select 'this is script A' what from dual;
    

    run_all.sql looks like this:

    @a
    @b
    @c
    

    Let's test it:

    SQL> @run_all
    
    WHAT
    ----------------
    this is script A
    
    
    WHAT
    ----------------
    this is script B
    
    
    WHAT
    ----------------
    this is script C
    
    SQL>
    

    See if it helps.