Teradata Fast Load
Script to load data from text file to Table
Step1:- Create one sample text file Lokesh.txt
Type: vi Lokesh.txt
= i
à
write the text file with below sample data
101,Mike,James,1980-01-05,2010-03-01,1
102,Robert,Williams,1983-03-05,2010-09-01,1
103,Peter,Paul,1983-04-01,2009-02-12,2
104,Alex,Stuart,1984-11-06,2014-01-01,2
105,Robert,James,1984-12-01,2015-03-09,3
= :wq (will save the file data and close)
Step2:- Create one shell script Lokesh.sh
type= vi Lokesh.sh
= i
à
Write the script like
fastload<<EOF
.logmech ldap;
.LOGON (Server Name)/(User Name),(Password); (ServerNM:PROD.welg.com,UN:Lokesh,PWD:12345)
SET RECORD
VARTEXT ",";
DEFINE
in_EmployeeNo (VARCHAR(10)),
in_FirstName
(VARCHAR(30)),
in_LastName
(VARCHAR(30)),
in_BirthDate
(VARCHAR(10)),
in_JoinedDate
(VARCHAR(10)),
in_DepartmentNo (VARCHAR(02))
FILE
="/opt/samples/lokesh.txt"; (File
Path)
BEGIN LOADING
DBPROD.TBLEMPLOYEE (DATABASE.TABLENAME)
ERRORFILES DBPROD.Employee_ERR1,
DBPROD.Employee_ERR2
CHECKPOINT
10;
INSERT INTO
" DBPROD "." TBLEMPLOYEE" (
EmployeeNo,
FirstName,
LastName,
BirthDate,
JoinedDate,
DepartmentNo
)
VALUES (
:in_EmployeeNo,
:in_FirstName,
:in_LastName,
:in_BirthDate
(FORMAT 'YYYY-MM-DD'),
:in_JoinedDate (FORMAT 'YYYY-MM-DD'),
:in_DepartmentNo
);
END LOADING;
.LOGOFF;
Type= :wq
Will save the shall script
Step3:- Execute the shell script to load text file data to
teradata table
Ksh Lokesh.sh