Professional Documents
Culture Documents
Teradata Architecture
Teradata Utilities(Client Tools)
BTEQ
Fast Load
Fast Export
Multiload
Tpump
BTEQ
• BTEQ is available on every Teradata system ever built, Because the
Basic Teradata Query Language(BTEQ) tool was the original way
that SQL was submitted to Teradata as a means of getting an
answer set in a desired format.
• BTEQ is also an excellent tool for importing and exporting data.
• BTEQ Sessions provides a quick and easy way to access a Teradata
RDBMS. In a BTEQ session, you can do the following
- enter Teradata SQL statements to view, add, modify, and
delete data.
- enter BTEQ commands.
- enter operating system commands.
• interactive mode -start a BTEQ session, and submit commands to
the database as needed.
• batch mode -prepare scripts or macros, and then submit them to
BTEQ for processing.
The BTEQ Command Set
The BTEQ command set can be categorized as:
Session control - begin and end BTEQ sessions, and
control session characteristics.
File control - specify input and output formats and
identify information sources and destinations.
Sequence control - control the sequence in which
other BTEQ commands and Teradata SQL statements
will be executed within scripts and macros.
Format control - control the format of screen and
printer output.
Session Control Commands
Use the following BTEQ commands to begin, control, and end
sessions.
LOGON - starts a BTEQ session.
SESSIONS - specify the number of sessions to use with the
next LOGON command.
LOGOFF - end the current sessions without exiting BTEQ.
EXIT or QUIT - end the current sessions and exit BTEQ.
ABORT - abort any active requests and transactions
without exiting BTEQ.
SHOW CONTROLS - display the current configuration of the
BTEQ
control command options.
SHOW VERSIONS - display the BTEQ version number, module
revision numbers, and linking date.
SESSION TRANSACTION - specify whether transaction
boundaries are determined by Teradata SQL semantics or ANSI
semantics.
COMPILE - create or replace a Teradata stored procedure.
Phase 1
• FastLoad uses one SQL session to define AMP steps.
• AMPs hash each record and redistribute them to the AMP responsible for
the hash value.
• The PE sends a block to each AMP which
stores blocks of unsorted data records.
Phase 2
• Each AMP sorts the target table, puts the rows into blocks, and writes the
blocks to disk.
• Fallback rows are then generated if required.
Error Tables
Error Table 1
Contains one row for each row which failed to be loaded
due to constraint violations or translation errors.
Error Table 2
Captures any error which is related to duplication of
values for Unique Primary Indexes (UPI). Fastload will
capture only one occurrence of the value and store the
duplicate occurrence in the second error table. However if
the entire row is duplicated then Fastload count it but does
not store the row.
FastLoad Commands
FastLoad Commands…
FastLoad Script
/* Number of Sessions */
SESSIONS 4;
/* Maximum Number of Errors allowed to occur */
ERRLIMIT 50;
.logon 127.0.0.1/DBC,DBC;
/* Dropping Error Tables */
DROP TABLE TRAINING.DEPTERR1;
DROP TABLE TRAINING.DEPTERR2;
DELETE FROM TRAINING.DEPT;
/*DEFINE FILE =C:\DEPT.TXT;
SHOW;*/
BEGIN LOADING TRAINING.DEPT ERRORFILES TRAINING.DEPTERR1, TRAINING.DEPTERR2;
/* Specifying the Type of File */
SET RECORD VARTEXT " ";
/* Defining the Columns in Flat File Format */
DEFINE
DEPT_NO (VARCHAR(20)),
DEPT_NAME (VARCHAR(50)),
/* Loading from Input File */
FILE =C:\Desktop\Sample_fload.txt;
/* Inserting Rows into the Table*/
INSERT INTO TRAINING.DEPT
VALUES
(:DEPT_NO,
:DEPT_NAME
);
.END LOADING;
.LOGOFF;
$ fastload < emp101.fl
Limitations
• If an AMP goes down, FastLoad cannot be restarted until it is back online
• Concatenation of Input Data Files are not allowed.
• NO SECONDARY INDEXES ARE ALLOWED ON TARGET TABLE –
Fastload can load tables only with primary indexes defined on it. If we have
a secondary index on the table then Fastload will not load that table.
• NO REFERENTIAL INTEGRITY IS ALLOWED – Fastload cannot load
data into tables that are defined with Referential Integrity (RI). This would
require too much system checking to prevent referential constraints to a
different table
• DUPLICATE ROWS ARE NOT SUPPORTED – Multiset tables are a
table that allow duplicate rows — that is when the values in every
column are identical. When Fastload finds duplicate rows, they are
discarded. While Fastload can load data into a multi-set table, Fastload will
not load duplicate rows into a multi-set table because Fastload discards
duplicate rows
Fast Export
Table A
Table B
update Insert
MultiLoad Table C
Delete
Table D
Host Table E
Server
MultiLoad Tasks
MultiLoad allows INSERT, UPDATE, DELETE and UPSERT
operations against up to five target tables per task.
Two distinct tasks are:
IMPORT task:
These are the tasks which intermix a number of different
SQL/DML statements and apply them to up to five different
tables depending on the APPLY conditions
DELETE task:
These are tasks which execute a single DELETE statement on
a single table.
5 Phases in Multiload
5 Phases in Multiload…
Tables in MultiLoad
Mload uses 2 Error tables(ET,UV), 1 Work table and 1 log table.
1.ET Table- Data Error
a. Also called as ACQUISITION PHASE ERROR TABLE
b. Is used to store data errors found during the acquisition phase of a multiload
import task
2. UV Table- UPI Violations
a. Also called as APPLICATION PHASE ERROR TABLE
b. Is used to store data errors found during the application phase of a multiload
import or delete task
3. Work Table-WT
a. MLOAD loads the selected records in the work table
4. Log Table
a. Maintains records of all checkpoints related to the load job, it is essential /
mandatory to specify a log table in mload job.
b. This table will be useful in case you have a job abort or restart due to any
reason
MultiLoad Commands
MultiLoad Commands…
MultiLoad Commands…
Sample MultiLoad Script
.LOGTABLE dwlogtable;
.LOGON tdp1/etltoolsinfo,dwpwd1;
Limitation:
1.The RELEASE MLOAD command is used to release the locks and rollback
the job. But if you have been loading multiple millions of rows, the rollback
may take a lot of time. For this reason, most customers would rather just go
ahead and RESTART.
2. Should be very cautious using the RELEASE command. It could
potentially leave your table half updated
MultiLoad Limitations