Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

.

EXPORT RESET --> command disables the previous EXPORT command and sends selection
results to the standard output stream. If not given it will automatically take the
reset command while the BTEQ script is taken for parsing.
*** To reset export, type .EXPORT RESET

LOGOFF Ends the current Teradata Database sessions without exiting BTEQ.
EXIT or QUIT Ends the current Teradata Database sessions and exits BTEQ.
EXIT or QUIT Exits BTEQ when the user is not logged on to the Teradata
Database.

.set separator '|'; -- to set the output field separator.

.SET session transaction btet; -- to set the TD transaction mode.

.IMPORT VARTEXT '|' FILE= "C:\Users\abc\Desktop\TD\abhishank.txt",skip=2; -- to


mention the delimiter in the input file while importing records.

create, alter, drop and insert, update,select, delete all work in BTEQ.

How to insert specific columns in a table while importing from file?


USING(EMP_NO VARCHAR(24),EMP_NM VARCHAR(24),abk varchar(24),DEPT_NO
VARCHAR(24),SALARY VARCHAR(24))

insert into infy_sep13.employee_imp (


EMP_NO
, EMP_NM
, DEPT_NO
, SALARY
)
values
( COALESCE(:EMP_NO,1)
, COALESCE(:EMP_NM,1)
, COALESCE(:DEPT_NO,1)
, COALESCE(:SALARY,1)
) ;

How to run fast export script?


fexp < script_nm

Sample fastexport
.LOGTABLE tduser.employee_log;
.LOGON 192.168.1.102/dbc,dbc;
DATABASE tduser;
.BEGIN EXPORT SESSIONS 2;
.EXPORT OUTFILE employeedata.txt
MODE RECORD FORMAT TEXT;
SELECT CAST(EmployeeNo AS CHAR(10)),
CAST(FirstName AS CHAR(15)),
CAST(LastName AS CHAR(15)),
CAST(BirthDate AS CHAR(10))
FROM
Employee;
.END EXPORT;
.LOGOFF;

Fastload sample

LOGON 192.168.1.102/dbc,dbc;
DATABASE tduser;
BEGIN LOADING tduser.Employee_Stg
ERRORFILES Employee_ET, Employee_UV
CHECKPOINT 10;
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 = employee.txt;
INSERT INTO Employee_Stg (
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;

Multiload script

.LOGTABLE tduser.Employee_log;
.LOGON 192.168.1.102/dbc,dbc;
.BEGIN MLOAD TABLES Employee_Stg;
.LAYOUT Employee;
.FIELD in_EmployeeNo * VARCHAR(10);
.FIELD in_FirstName * VARCHAR(30);
.FIELD in_LastName * VARCHAR(30);
.FIELD in_BirthDate * VARCHAR(10);
.FIELD in_JoinedDate * VARCHAR(10);
.FIELD in_DepartmentNo * VARCHAR(02);

.DML LABEL EmpLabel;


INSERT INTO Employee_Stg (
EmployeeNo,
FirstName,
LastName,
BirthDate,
JoinedDate,
DepartmentNo
)
VALUES (
:in_EmployeeNo,
:in_FirstName,
:in_Lastname,
:in_BirthDate,
:in_JoinedDate,
:in_DepartmentNo
);
.IMPORT INFILE employee.txt
FORMAT VARTEXT ','
LAYOUT Employee
APPLY EmpLabel;
.END MLOAD;
LOGOFF;

You might also like