Teradata DMLs in a file can executed in background using 'nohup'.

Teradata: Run Commands in Background



NOHUP Script: Sample nohup script ( Download 'nohup_sample_script.bteq' ) to run Teradata commands(DMLs) in bteq
#nohup_sample_script.bteq

bteq <<_END_
.logon localhost/tutorial_user,tutorial_user
.run  file=$1;
_END_
  Note: Above script will get the file to be executed as parameter($1) from nohup command. Before running, provide the proper execution permission to the nohup script.


Run Nohup Script : 'nohup' command can be used to run process in background.
nohup ./nohup_sample_script.bteq test.dml > logfile.log &
  Note: As we have specified the log redirection, logs from the command execution will be stored on 'logfile.log'


Teradata DML File: Although the sample DML file (Download test.dml) shared below will execute within seconds but these commands can be replaced with required DMLs.
--test.dml

CREATE MULTISET TABLE TUTORIAL_DB.EMPLOYEE(
  emp_no INTEGER,
  emp_name VARCHAR(50),
  job_title VARCHAR(30),
  manager_id INTEGER,
  hire_date Date,
  salary DECIMAL(18,2),
  commission DECIMAL(18,2),
  dept_no INTEGER
)
Primary Index(emp_no);


INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000245, 'PRADEEP', 'PRESIDENT', null, '1981-11-17', 5000, null, 100);
INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000258, 'BLAKE', 'SENIOR MANAGER', 1000245, '1981-05-01', 2850, null, 300);
INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000262, 'CLARK', 'MANAGER', 1000245, '1981-06-09', 2450, null, 100);
INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000276, 'JONES', 'MANAGER', 1000245, '1981-04-02', 2975, null, 200);
INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000288, 'SCOTT', 'SYSTEM ANALYST', 1000276, '1987-07-13', 3000, null, 200);
INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000292, 'FORD', 'SYSTEM ANALYST', 1000276, '1981-12-03', 3000, null, 200);
INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000294, 'SMITH', 'LDC', 1000292, '1980-12-17', 800, null, 200);
INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000299, 'ALLEN', 'SALESMAN', 1000258, '1981-02-20', 1600, 300, 300);
INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000310, 'WARD', 'SALESMAN', 1000258, '1981-02-22', 1250, 500, 300);
INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000312, 'MARTIN', 'SALESMAN', 1000258, '1981-09-28', 1250, 1400, 300);
INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000315, 'TURNER', 'SALESMAN', 1000258, '1981-09-08', 1500, 0, 300);
INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000326, 'ADAMS', 'LDC', 1000288, '1987-07-13', 1100, null, 200);
INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000336, 'JAMES', 'LDC', 1000258, '1981-12-03', 950, null, 300);
INSERT INTO TUTORIAL_DB.EMPLOYEE VALUES( 1000346, 'MILLER', 'LDC', 1000262, '1982-01-23', 1300, null, 100);