Home > Software engineering >  Run .sql files in sequence on sqlplus
Run .sql files in sequence on sqlplus

Time:12-02

We have multiple .sql files and is there any way we can run them in single job ?

Sample files.

 @task1.sql ; 
 @task2.sql ; 
 @task3.sql ; 

Is there any way can I put all 3 above files in single files and run?

CodePudding user response:

Well ... yes.

task_main.sql:

@task1.sql
@task2.sql

task1.sql:

select deptno, ename, job, sal
from emp
where deptno = 10;

task2.sql:

select * from dept;

Running task_main from SQL*Plus:

SQL> @task_main

    DEPTNO ENAME      JOB              SAL
---------- ---------- --------- ----------
        10 CLARK      MANAGER         2450
        10 KING       PRESIDENT       5000
        10 MILLER     CLERK           1300


    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON

SQL>
  • Related