0% found this document useful (0 votes)
5 views3 pages

Bteq Findings

The document provides examples of commands used in the BTEQ scripting language for Teradata. It includes commands for resetting exports, setting session properties, importing and exporting data, and performing fastload and multiload operations. Samples scripts are given for fast export, fastload, and multiload to load data into Teradata tables from files.

Uploaded by

bhn9yfnz8m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Bteq Findings

The document provides examples of commands used in the BTEQ scripting language for Teradata. It includes commands for resetting exports, setting session properties, importing and exporting data, and performing fastload and multiload operations. Samples scripts are given for fast export, fastload, and multiload to load data into Teradata tables from files.

Uploaded by

bhn9yfnz8m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy