1

I have bunch of sql-scripts used to create various tables, procedures, functions and views. Everything is in separate files; is there a good way to bundle these and run each file in a specific order? Merging/concatenating all the files into one is also a possibility, but I'd prefer a bundle if possible.

Example (fictional/pseudocode): Master.sql contains the following:

src: DDL/table1.sql
src: DDL/table2.sql
src: fns/function1.sql
src: fns/function2.sql
src: views/view1.sql

...and so on. Running Master.sql would then execute each of the scripts listed in the file in the order listed. Is something like this possible?

1
  • The answer obviously depends on what client you use to run your scripts.
    – mustaccio
    Commented Feb 23, 2017 at 14:32

2 Answers 2

0

Prepend the scripts with an @ in your master.sql script:

@DDL/table1.sql
@DDL/table2.sql
@fns/function1.sql
@fns/function2.sql
@views/view1.sql
0

You can run them in SQLPlus like this;

@DDL/table1.sql
@DDL/table2.sql
@fns/function1.sql
@fns/function2.sql
@views/view1.sql

Make sure each one commits where necessary and don't finish each individual script with EXIT.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.