You are on page 1of 119

Teradata BTEQ

and Utilities

1 2012 WIPRO LTD | WWW.WIPRO.COM


Agenda

1 BTEQ

2
Fast Export

3
Fast Load

4
Multi Load

5
TPump

2 2012 WIPRO LTD | WWW.WIPRO.COM


Agenda (Contd.).

6 Teradata Parallel Transporter (TPT)

7
Compare Utilities

8
Overview of other Tools

3 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ

4 2012 WIPRO LTD | WWW.WIPRO.COM


Objectives

After completing this lesson, you will be able to:


List Feature of BTEQ
State BTEQ Export and Import capabilities
State BTEQ Export modes Data, Indicdata, Report, DIF modes
Prepare and run BTEQ export scripts
State BTEQ Import modes Data, Indicdata, Report, VARTEXT
Prepare and run BTEQ import scripts
Write BTEQ Scripts using Session, File, Sequence and Format features

5 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ
BTEQ , Basic TEradata Query - pronounced BEE-teek , is a
general-purpose command-driven utility

Used to access and manipulate data on the Teradata Database

Generate reports

Perform data movement -Export and Import (suitable for small


volume)

BTEQ is a transparent interface to CLI, to transmit textual SQL to


Teradata server, and deliver response to the user

Limited ability to branch using LABEL

Runs on every supported platform LAN and Channel Attached


Clients
6 2012 WIPRO LTD | WWW.WIPRO.COM
BTEQ

7 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ .EXPORT

BTEQ .EXPORT command is used to export data records from


Teradata database to a client system.

Format of the EXPORT command:


.EXPORT <mode> {FILE | DDNAME } = filename [, LIMIT=n]

EXPORT modes :
Data Mode (also called Record mode): .EXPORT DATA
Report Mode (also called Field mode, Default mode):
.EXPORT REPORT
Indicator Mode : .EXPORT INDICDATA
DIF (Data Interchange Format) Mode: .EXPORT DIF

For a channel-attached client, the output file is specified as


DDNAME instead of FILE

LIMIT=n Return n rows

8 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ EXPORT Demos

1. Write a BTEQ script to export EMP table rows in DATA mode


to the flat file. Run the script file in batch mode. Observe the
flat file and outfile.

Refer Notes Page for Script

Run script file from command line :

BTEQ < SCRIPT_FILE_NAME > OUTFILE_NAME

9 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ EXPORT Demos (Contd.).

2. Write a BTEQ script to export EMP table rows in REPORT


mode to the flat file. Run the script file in batch mode. Limit
number of rows exported to 10. Observe the flat file and
outfile

Refer Notes Page for Script

10 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ EXPORT Demos (Contd.).

3. Write a BTEQ script to export EMP table rows in INDICDATA


mode to the flat file. Run the script file in batch mode.
Observe the flat file and outfile

Refer Notes Page for Script

11 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ EXPORT Demos (Contd.).

4. Write a BTEQ script to export EMP table rows to EXCEL file.


Run the script file in batch mode. Observe the EXCEL file
and outfile

Refer Notes Page for Script

12 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ IMPORT

BTEQ .IMPORT command is used to import data from the host


to Teradata database as a series of INSERTs, UPDATEs,
DELETEs

Format of the EXPORT command:

.IMPORT <mode> {FILE | DDNAME } = filename [, SKIP=n]

IMPORT modes
Data Mode (also called Record mode): .EXPORT DATA
Report Mode (also called Field mode, Default mode): .EXPORT
REPORT
Indicator Mode : .EXPORT INDICDATA
VARTEXT mode

SKIP=n Skips initial n record

13 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ IMPORT Demos

1. Create a NEW_EMP table with the same structure as EMP


table with no data

CREATE NEW_EMP AS EMP WITH NO DATA;

2. Write BTEQ script to import data into NEW_EMP table from


the flat file containing rows in DATA format. Delete all rows
from NEW_EMP table. Run the script. Observe the data
(NULL values?) in NEW_EMP table.

Refer Notes Page for Script

14 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ IMPORT Demos (Contd.).

3. Write BTEQ script to import data into NEW_EMP table from


the flat file containing rows in REPORT format. The first 2
rows need to be skipped as they contain column headings.
Replace blank values with NULL. Delete all rows from
NEW_EMP table. Run the script. Observe the outfile and data
in NEW_EMP table.

Refer Notes Page for Script

15 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ IMPORT Demos (Contd.).

4. Write BTEQ script to import data into NEW_EMP table from


the flat file containing rows in INDICDATA format. Delete all
rows from NEW_EMP table. Run the script. Observe the data
(NULL values) in NEW_EMP table.

Refer Notes Page for Script

16 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ IMPORT Demos (Contd.).

5. Import data into NEW_EMP table from the EXCEL file. Delete
all rows from NEW_EMP table. Run the script. Observe the
data in NEW_EMP table.

Open the .xls file, save it as CSV (MS DOS) format.

Open the CSV text file and observe the date format and
delimiter.

Write BTEQ script to import data into NEW_EMP table from


the flat file containing rows in CSV format. Delete all rows
from NEW_EMP table. Run the script. Observe the data in
NEW_EMP table.

Refer Notes Page for Script

17 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ IMPORT Demos (Contd.).

6. Update NEW_EMP table, set SAL=NULL for all rows. Write


BTEQ script to update SAL of all employee rows in
NEW_EMP table from the flat file containing rows in DATA
format. Run the script. Observe the data in NEW_EMP table.

Refer Notes Page for Script

18 2012 WIPRO LTD | WWW.WIPRO.COM


BTEQ Command Set

BTEQ commands can be classified as follows:

Session control commands

File control commands

Sequence control commands

Format control commands

19 2012 WIPRO LTD | WWW.WIPRO.COM


Session Control

Session control commands begin and end BTEQ sessions,


and control session characteristics;

LOGON
SESSIONS
LOGOFF
QUIT,EXIT
SHOW CONTROLS
SESSION DATEFORM

Online Demo of difference between ANSI and BTET


Transaction mode Sessions
How do you set the session mode parameters in BTEQ?

.set session transaction ANSI /* this is to set ANSI mode */


.set session transaction BTET /* this is to set Teradata transaction mode */

20 2012 WIPRO LTD | WWW.WIPRO.COM


File Control

Specify the format of incoming/ outgoing information and


identify the source and destination of input/output streams.

OS
RUN
IMPORT
REPEAT
QUIT
EXPORT
INDICDATA/RECORDMODE

21 2012 WIPRO LTD | WWW.WIPRO.COM


Sequence Control

Controls the sequence in which other BTEQ commands and


SQL statements will be executed within the scripts and
macros.

IF THEN
ELSE
ENDIF
GOTO

22 2012 WIPRO LTD | WWW.WIPRO.COM


Conditional Logic Example

.SET QUIET ON
DELETE FROM DEPTSUM;
.IF ERRORCODE = 0 THEN .GOTO TABLEOK;
CREATE TABLE DEPTSUM
(DEPTNO INTEGER,
DEPT_TOT INTEGER);
.LABEL TABLEOK;
INSERT INTO DEPTSUM
SELECT DEPTNO, SUM(SAL)FROM EMP
GROUP BY DEPTNO;
.IF ACTIVITYCOUNT > 0 THEN .GOTO CONTINUE
.QUIT
.LABEL CONTINUE

23 2012 WIPRO LTD | WWW.WIPRO.COM


Format Control
To specify the way in which BTEQ presents information on the
screen/printer.

Commands:
FOOTING
HEADING
RETLIMIT
FOLDLINE
SUPPRESS
QUIET
NULL
WIDTH
UNDERLINE
SEPARATOR

Online Demo of BTEQ Formatting Feature


24 2012 WIPRO LTD | WWW.WIPRO.COM
Summary

In this lesson you learnt about:

Feature of BTEQ
BTEQ Export and Import capabilities
BTEQ Export modes Data, Indicdata, Report, DIF modes
Prepare and run BTEQ export scripts
BTEQ Import modes Data, Indicdata, Report, VARTEXT
Prepare and run BTEQ import scripts
Writing BTEQ Scripts using Session, File, Sequence and Format
features

25 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Export

26 2012 WIPRO LTD | WWW.WIPRO.COM


Objectives

At the end of this lesson, you will be able to:


State Fast Export capabilities and limitations
List Fast Export commands, Options, Formats and
Modes
Handle errors and Restart
Prepare and run Fast Export scripts

27 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Export

To export large volume of data from Teradata database to


client.

Takes advantage of multiple sessions.

Exports from multiple tables.

Can be used with INMOD/OUTMOD feature for external data


sources and destinations.

Fully automated restart

Teradata accommodates not more than 60 LOAD applications


at any one time (FastLoad, MultiLoad, FastExport).

28 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Export Commands

.BEGIN EXPORT
SESSIONS max min
TENACITY hours
SLEEP minutes
NOTIFY high | medium | low | ;

.END EXPORT
Delimits a series of commands that define a single EXPORT action
Must be the last directive in a Fast Export script
Causes the utility to send the SELECT to the Teradata Database

.EXPORT OUTFILE filename


FORMAT fastload| text | binary | unformat
MODE indicator | record

29 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Export Options

SELECT Statement
Defines the data to be returned to the client
Multiple SELECTs are allowed
Applies READ lock
Locks are released when all response rows are moved to AMP spool
Supports the LOCKING FOR ACCESS modifier to request an access
lock
Following are not allowed in SELECT
Non-data tables (ex CURRENT_DATE,)
Equality condition for PI or USI
WITH option to generate total or subtotal response rows

Variable input to Fastexport


From file containing single record : ACCEPT
From file containing multiple record : IMPORT

30 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Export Errors and Restart

After Job Script Error


Generates diagnostic error messages with nonzero return code
Modify the script and correct the error
Resubmit the Job Script
Job resumes processing at the statement following last one that
completed normally

After Hardware Failures


FastExport restarts automatically after system recovery

31 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Export Demos

1. Write a fastexport script to export RETAIL.CLIENT data to a


flat file. Include records with c_nationkey= 8 and
c_mktsegment= 'HOUSEHOLD only and use MLSCRIPT
option to generate the multi load script file.

Refer Notes Page for Script

32 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Export Demos (Contd.).

2. Write a fastexport script to perform multiple exports in a


single script. Limit number of records to 10.

Refer Notes Page for Script

33 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Export Demos (Contd.).

3. Write a fastexport script to accept input values (nationkey and


mktsegment) from a single record flat file and export
RETAIL.CLIENT data to a flat file.

Refer Notes Page for Script File

34 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Export Demos (Contd.).

4. Write a fastexport script to import input values (nationkey and


mktsegment) from a multi record flat file and export
RETAIL.CLIENT data in text (readable) format to a flat file.
Include only C_NAME, C_NATIONKEY, C_MKTSEGMENT
columns.

Refer Notes Page for Script File

35 2012 WIPRO LTD | WWW.WIPRO.COM


Summary

In this lesson you learnt about:


Fast Export capabilities and limitations
Fast Export commands, Options, Formats and Modes
Handling errors and Restart
Prepare and run Fast Export scripts

36 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Load

37 2012 WIPRO LTD | WWW.WIPRO.COM


Objectives

After completing this lesson, you will be able to:


List capabilities and limitations of Fast Load
Describe the two phases of Fast Load
List Fast Load commands
Handle errors and Restart
Prepare and run Fast Load scripts

38 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Load

Load large amounts of data into an empty table at high speed


Meant to populate empty tables with INSERTS
Takes advantage of multiple sessions.
Loads data at the block level (64 K block)
Fully automated restart
Checkpoints can be taken for restarts.
Locks at the table level
Data can be loaded in multiple stages
Can be used with INMOD feature for external data sources and
destinations.
Teradata accommodates not more than 60 LOAD applications
at any one time (Fast Load, Multi Load, Fast Export)

39 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Load - Restrictions

Only one table may be loaded at a time with one fast load job
Tables defined with RI, SI, JI, HI and Triggers cannot be loaded
Duplicate rows cannot be loaded into multiset table
If an AMP goes down, Fast Load cannot be restarted until it is
back online

40 2012 WIPRO LTD | WWW.WIPRO.COM


Two phases of Fast Load

Phase 1
Establishes the sessions for FastLoad task
Host sends data blocks through the sessions
PEs receive the data blocks and directly send them to AMPs
AMPs redistributes the data rows to their target AMPs
AMPs writes the blocks (unsorted) to the disk

Phase II
Phase 2 start when END LOADING command received
AMPs read their blocks and sort them based on row hash
sequence
Write the sorted data blocks back to the disk
Fallback copy of the data is created
Table is available when phase 2 completes

41 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Load Commands

BEGIN LOADING [dbname.]table_name


ERRORFILES [dbname.]err_table_1, [dbname.]err_table_2
[CHECKPOINT integer]
[INDICATORS];
Err_table_1 :
Contains one row for each row which failed to be loaded due to constraint
violations or conversion errors. The table has 3 columns ErrorCode,
ErrorFieldName, and DataParcel

Err_table_2 :
For non-duplicate rows, captures those rows that cause a UPI violation
Duplicate rows are counted and reported but not captured
Error table are automatically dropped if empty upon completion of
the run
There will be a row in SYSADMIN.FASTLOG table for each Fast
Load job that has not completed in the system

42 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Load - Restart ability

CHECKPOINT integer : Specifies the number of rows transmitted


before pausing to take a checkpoint and varify receipt by AMPs.
If CHECKPOINT is not specified, Fast Load takes checkpoints as
follows:
Beginning of Phase 1
Every 1,00,000 input records
End of Phase 1
Fast Load can be restarted from previous checkpoint
Checkpoints slow Fast Load processing Set the checkpoint large
enough that checkpoints are taken every 10 to 15 minutes.

END LOADING
Indicates that all data rows have been transmitted.
Begins Phase 2 processing
Omission implies that the load is incomplete and will be restarted later

43 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Load Errors and Restart

After Job Script Error


Generates diagnostic error messages with nonzero return code
Modify the script and correct the error
Resubmit the Job Script
Job resumes processing at the statement following last one that
completed normally

Paused during Loading Phase


Resubmit the script
Job resumes processing from latest checkpoint (reads from restart log
table)
Paused during End Loading Phase
LOGON
BEGIN LOADING target_table
ERRORFILES err1,err2;
ENDLOADING

44 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Load Demos

1. Create a NEW_EMP table with the same structure as EMP


table with no data. UPI EMPNO.

CREATE TABLE NEW_EMP AS EMP WITH NO DATA;

2. Write Fast Load script to import data into NEW_EMP table


from the flat file containing rows in DATA format. Delete all
rows from NEW_EMP table. Run the script. Observe the data
(NULL values?) in NEW_EMP table.

Refer Notes Page for Script

45 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Load Demos (Contd.).

3. Write Fast Load script to import data into NEW_EMP table


from the flat file containing rows in REPORT format. The first
2 rows need to be skipped as they contain column headings.
Replace blank values with NULL. Delete all rows from
NEW_EMP table. Run the script. Observe the outfile and data
in NEW_EMP table.

Refer Notes Page for Script

46 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Load Demos (Contd.).

4. Write Fast Load script to import data into NEW_EMP table


from the flat file containing rows in INDICDATA format.
Delete all rows from NEW_EMP table. Run the script.
Observe the data (NULL values) in NEW_EMP table.

Refer Notes Page for Script

47 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Load Demos (Contd.).

5. Write Fast Load script to import data into NEW_EMP table


from the flat file containing data in CSV format. Delete all
rows from NEW_EMP table. Run the script. Observe the data
in NEW_EMP table.

Refer Notes Page for Script

48 2012 WIPRO LTD | WWW.WIPRO.COM


Fast Load Demos (Contd.).

6. Write a Fast Load script to load data into NEW_EMP table from
multiple flat files.

Refer Notes Page for Script file to load data from first flat file

Try to access the table and note down your observation

Refer Notes Page for Script file to load data from second flat file

Refer Notes Page for Script file to end the fast load job

Try to access the table and note down your observation

49 2012 WIPRO LTD | WWW.WIPRO.COM


Summary

In this lesson you learnt about:


List capabilities and limitations of Fastload
Describe the two phases of Fastload
List Fastload commands
Handle errors and Restart
Prepare and run Fastload scripts

50 2012 WIPRO LTD | WWW.WIPRO.COM


Multi Load

51 2012 WIPRO LTD | WWW.WIPRO.COM


Objectives

At the end of this lesson, you will be able to:


List capabilities and limitations of Multiload
Describe the five phases of Multiload
Describe the two Multiload Tasks
Handle errors and Restart
Release multiload job
Prepare and run Multiload scripts for DML operations
Compare FastLoad and Multiload

52 2012 WIPRO LTD | WWW.WIPRO.COM


Multi Load

Used for high volume data maintenance


Supports INSERTs, UPDATEs and DELETEs.
Loads up to five tables in a single job.
Tables need not be empty.
Loads data at the block level (64 K block)
Input data rows can be applied conditionally to DML requests.
Supports UPSERTs.
Tables defined with RI, USI, JI, HI and Triggers cannot be
loaded
Tables with NUSI can be loaded using Multiload.
Can be used with INMOD feature for external data sources and
destinations
Teradata accommodates not more than 60 LOAD applications
at any one time (Fast Load, Multi Load, Fast Export)

53 2012 WIPRO LTD | WWW.WIPRO.COM


Multi Load Tasks
IMPORT task
Multiple combinations of INSERTs/UPDATEs/DELETEs/UPSERTs
are supported against up to five target tables per job. However, not
allowed to change the value of a tables PI
Where condition must be an equality condition on primary Index
Permits non-exclusive access to target tables from other users
except during Application Phase

DELETE task
These are tasks which execute a single DELETE statement on a
single table.
Deleting based on a UPI access is not permitted
No Acquisition phase because no variable input records to apply
Multi Load DELETE is faster and uses less disk space (No transient
Journal)
Multi Load DELETE is restartable
All other aspects similar to IMPORT task

54 2012 WIPRO LTD | WWW.WIPRO.COM


5 Phases of MuliLoad IMPORT task

1. Preliminary Phase
Start Multiload sessions
Parses and validates MultiLoad and SQL Statements
Create work tables : one per target table
Create error tables : two per target table
Create Restart log table
Apply utility locks (disallow DDLs) on target tables.
2. DML Transaction Phase
Send DML requests to server.
3. Acquisition Phase (for IMPORT task only)
Client sends data buffers to server
AMPs receives the data blocks and redistributes (by row hash) each
data records to its target AMPs.
Data rows are accumulated in work tables of corresponding target
table.
There is no acquisition phase for DELETE task
Error go to ET_tablename

55 2012 WIPRO LTD | WWW.WIPRO.COM


5 Phases of MuliLoad IMPORT task (Contd.).

4. Application Phase
Acquires write locks on the target tables.
For IMPORT task, applies work table changes to target table
For DELETE task, deletes the specified rows from the target
table
Affected blocks read/written only once
NUSI subtable changes applied
Errors go to UV tablename

5. Clean-up Phase
Release locks on the target tables
Forces an automatic rebuild of target table if an AMP went
down and came back online during the application phase
Drop empty error tables, work table and log table
Report load statistics
Logoff sessions

56 2012 WIPRO LTD | WWW.WIPRO.COM


Errors, Restart and Release MultiLoad Job

Multiload job terminated due to a client failure can be


resubmitted to continue from the point of failure.
Multiload uses checkpoint and log table mechanism for restart
recovery.
RELEASE MLOAD T1,T2...[IN APPLY] ;

use IN APPLY only when the MultiLoad task was in the application
phase when it was suspended
must be exec from bteq or SQLA
this only releases the lock on target tables - we need to manually drop
the WT_* (worktable),ET_*(aquisition phase err table),UV_*(application
phase errrortable) and Checkponit Restart Log tables.

CHECKPOINT n;
n <=60 n is number of minutes
n > 60 n is number of records
n=0 no checkpoints yet all
default checkpoint is every 15 mins
57 2012 WIPRO LTD | WWW.WIPRO.COM
Multi Load Demos
1. Create a NEW_EMP table with the same structure as EMP
table with no data. UPI EMPNO.

CREATE TABLE NEW_EMP AS EMP WITH NO DATA;

2. Write Multi Load script to UPSERT data into NEW_EMP table


from the flat file containing rows in DATA format. Delete all
rows from NEW_EMP table. Run the script. Observe the data
(NULL values?) in NEW_EMP table.

Refer Notes Page for Script

58 2012 WIPRO LTD | WWW.WIPRO.COM


Multi Load Demos (Contd.).

3. Observe UPSERT operation

UPDATE new_emp SET sal=NULL;

DELETE FROM new_emp WHERE deptno=10;

Rerun the previous script file to set sal to its original value
and insert missing records.

59 2012 WIPRO LTD | WWW.WIPRO.COM


Multi Load Demos (Contd.).

4. Write Fast Load script to UPSERT data into new employee


table from the flat file containing rows in REPORT format.
The first 2 rows need to be skipped as they contain column
headings. Replace blank values with NULL. Delete all rows
from NEW_EMP table. Run the script. Observe the outfile and
data in NEW_EMP table.

Refer Notes Page for Script

60 2012 WIPRO LTD | WWW.WIPRO.COM


Multi Load Demos (Contd.).

5. Write Multi Load script to UPSERT data into NEW_EMP table


from the flat file containing rows in INDICDATA format.
Delete all rows from NEW_EMP table. Run the script.
Observe the data (NULL values) in NEW_EMP table.

Refer Notes Page for Script

61 2012 WIPRO LTD | WWW.WIPRO.COM


Multi Load Demos (Contd.).

6. Write Multi Load script to UPSERT data into NEW_EMP table


from the flat file containing data in CSV format. Delete all
rows from NEW_EMP table. Run the script. Observe the data
in NEW_EMP table.

Refer Notes Page for Script

62 2012 WIPRO LTD | WWW.WIPRO.COM


Multi Load Demos (Contd.).

7. Write a Multi Load script to update salary of employees and


delete employee records from NEW_EMP table, according to
a txn code in the input file. All transaction records need to be
inserted into EMP_TRANS (trans_code, empno, trans_date
columns) table.

Refer Notes Page for Script Conditional DML and


Mutitable

63 2012 WIPRO LTD | WWW.WIPRO.COM


Multi Load Demos (Contd.).

8. Write a Multi Load script to delete all employees in DEPTNO


20 from NEW_EMP table.

Refer Notes Page for Script

64 2012 WIPRO LTD | WWW.WIPRO.COM


Multi Load Demos (Contd.).

9. Write a Multi Load script to import the given DEPTNO input


value from a flat file and delete all employees in the given
deptno value from NEW_EMP table.

Refer Notes Page for Script

65 2012 WIPRO LTD | WWW.WIPRO.COM


Compare Fast Load and Multi Load
Fastload Multiload
RI, SI, JI,HI, Triggers No Only NUSI
DML INSERT I/P/D & Conditional DML
Multiple DML No Yes
Multiple tables No Yes
Multiple sessions Yes Yes
Protocol Used FASTLOAD MULTILOAD
Work Table No Yes
Target Table Empty Empty or Populated
Lock Throughout Only Application Phase
Error files Yes Yes
Error limits Yes Yes
User routines Yes Yes

66 2012 WIPRO LTD | WWW.WIPRO.COM


Summary

In this lesson you learnt about:


Capabilities and limitations of Multiload
Five phases of Multiload
Multiload Import and Delete Tasks
Handling errors and Restart
Releasing multiload job
Prepare and run Multiload scripts
Compare FastLoad and Multiload

67 2012 WIPRO LTD | WWW.WIPRO.COM


TPump

68 2012 WIPRO LTD | WWW.WIPRO.COM


Objectives

At the end of this lesson, you will be able to:


List capabilities and limitations of TPump
Compare TPump with Mload
Handle errors and Restart
Prepare and run TPump scripts for DML operations

69 2012 WIPRO LTD | WWW.WIPRO.COM


TPump

Teradata Parallel Data Pump


Allows near real-time updates from transactional systems into the
warehouse.
Best fit for low volume data maintenance.
Unlike Multiload, Tpump uses row hash lock allows concurrent
updates on the same table.
INSERT,UPDATE, DELETE supported.
No restrictions applied for tables with SI, RI, triggers etc.
No limit on number of concurrent sessions.
Speed can be tuned dynamically, can specify how many updates
occur minute by minute.
Target tables can be SET, MULTISET, Populated, Empty
Exponential, Aggregate operators and Arithmetic functions are not
allowed
There is a limit of four IMPORT commands within a single TPump
load task

70 2012 WIPRO LTD | WWW.WIPRO.COM


TPump versus MultiLoad
Function MultiLoad TPump

Error tables must be Optional, 2 per target Optional, 1 per target


defined table table
Work tables must be Optional, 1per target No
defined table
Log table must be defined Yes Yes
Allows RI, USI, Triggers No Yes
Allows NUSI Yes Yes
Load a max of N tables 5 60
Max concurrent load 60 Unlimited
Instances
Locks Table Row
DML processing Runs actual DMLs DML into Macros
Transfers data in 64K Yes No, move data at row
blocks level

71 2012 WIPRO LTD | WWW.WIPRO.COM


TPump Errors and Restart

After Job Script Error


Generates diagnostic error messages with nonzero return code
Modify the script and correct the error
Resubmit the Job Script
Job resumes processing at the statement following last one that
completed normally

Paused / Aborted TPump


Resubmit the script
Job resumes processing from latest checkpoint (reads from
restart log table)

72 2012 WIPRO LTD | WWW.WIPRO.COM


TPump in Active Data Warehouse

TPump is suitable, when some of the data needs to be


updated closer to the time the event or the transaction took
place

Avoids table-level locks (row-hash locks only)

Concurrent table SQL access during updates

Flexibility in when and how it is executed

Queries can access a table concurrently with TPump

Several TPump jobs can run against the same table at the
same time

73 2012 WIPRO LTD | WWW.WIPRO.COM


TPump Key Variables

The TPump key variables, in order of greatest potential impact


on performance, are the following (BEGIN LOAD):

PACK

SESSIONS (number)

SERIALIZE (ON or OFF)

CHECKPOINT (mins)

ROBUST (ON or OFF)

Refer Notes for Details

74 2012 WIPRO LTD | WWW.WIPRO.COM


TPump Real Time Usage Scenarios

(I) Large, high volume

(II) Small, highly time-critical bursts

(III) Extract from OLTP database

(IV) Multi-Source batch

(V) Variable arrival rates, low volume

(VI) TPump in a Continuous Environment

Refer Notes Page for Details

75 2012 WIPRO LTD | WWW.WIPRO.COM


TPump Demos
1. Create a NEW_EMP table with the same structure as EMP table
with no data. UPI EMPNO.

CREATE TABLE NEW_EMP AS EMP WITH NO DATA;

2. Write TPump script to UPSERT data into NEW_EMP table from


the flat file containing rows in DATA format. Delete all rows from
NEW_EMP table. Run the script. Observe the data (NULL
values?) in NEW_EMP table.

Refer Notes Page for Script

3. UPDATE new_emp SET sal=NULL; DELETE FROM new_emp


WHERE deptno=10; Rerun the script file to set sal to its original
value and insert missing records.

76 2012 WIPRO LTD | WWW.WIPRO.COM


TPump Demos (Contd.).

4. Write TPump script to UPSERT data into NEW_EMP table


from the flat file containing rows in REPORT format. The first
2 rows need to be skipped as they contain column headings.
Replace blank values with NULL. Delete all rows from
NEW_EMP table. Run the script. Observe the outfile and data
in NEW_EMP table.

Refer Notes Page for Script

77 2012 WIPRO LTD | WWW.WIPRO.COM


TPump Demos (Contd.).

5. Write TPump script to UPSERT data into NEW_EMP table


from the flat file containing rows in INDICDATA format.
Delete all rows from NEW_EMP table. Run the script.
Observe the data (NULL values) in NEW_EMP table.

Refer Notes Page for Script File

78 2012 WIPRO LTD | WWW.WIPRO.COM


TPump Demos (Contd.).

6. Write TPump script to UPSERT data into NEW_EMP table


from the flat file containing data in CSV format. Delete all
rows from NEW_EMP table. Run the script. Observe the data
in NEW_EMP table.

Refer Notes Page for Script

79 2012 WIPRO LTD | WWW.WIPRO.COM


TPump Demos (Contd.).

7. Write a TPump script to update salary of employees and


delete employee records from NEW_EMP table, according to
a transaction code in the flat file. All transaction records need
to be inserted into EMP_TRANS (trans_code, empno,
trans_date columns) table.

Refer Notes Page for Script

80 2012 WIPRO LTD | WWW.WIPRO.COM


Summary

In this lesson you learnt about:


Capabilities and limitations of TPump
Compare TPump with Mload
Handling errors and Restart
Prepare and run TPump scripts for DML operations

81 2012 WIPRO LTD | WWW.WIPRO.COM


Teradata Parallel Transporter - TPT

82 2012 WIPRO LTD | WWW.WIPRO.COM


Objectives

After completing this lesson, you will be able to:


Describe capabilities TPT
Compare TPT with other tools
Load and Unload using TPT Wizard
Load using TPT EasyLoader
Use TPT Utility Commands
Prepare and run TPT scripts

83 2012 WIPRO LTD | WWW.WIPRO.COM


Teradata Parallel Transporter (TPT)

Teradata Parallel Transporter is a load/update/export tool that


enables data extraction, transformation and loading
Using built-in operators, Teradata Parallel Transporter
combines the functionality of the Teradata utilities (FastLoad,
MultiLoad, FastExport, and TPump) in a single parallel
environment
Its extensible environment supports FastLoad INMODs,
FastExport OUTMODs, and Access Modules to provide access
to all the data sources
There is a set of open APIs (Application Programmer
Interface) to add third party or custom data transformation to
Teradata Parallel Transporter scripts.
Teradata Parallel Transporter provides a single, SQL-like
scripting language, as well as a GUI to make scripting faster
and easier

84 2012 WIPRO LTD | WWW.WIPRO.COM


TPT (Contd.).

Using multiple, parallel tasks, a


single Teradata Parallel
Transporter script can load data
from disparate sources into the
Teradata Database in the same job

Data files can be processed in


parallel with the Directory Scan
feature included in the Teradata
Parallel Transporter solution

Checkponit Restart

85 2012 WIPRO LTD | WWW.WIPRO.COM


TPT (Contd.).

Unlike conventional utilities in which


multiple data sources are processed
in a serial manner, TPT can access
multiple data sources in parallel.
This ability can lead to increased
throughput.

TPT also allows different


specifications for different data
sources and merges them together

TPT eliminates the need for


intermediate file storage by holding
data in data buffers

86 2012 WIPRO LTD | WWW.WIPRO.COM


TPT (Contd.).
TPT Operator Teradata Utility Description
LOAD FastLoad A consumer-type operator that uses the Teradata
FastLoad protocol. Supports Error limits and
Checkpoint/ Restart. Both support Multi-Value
Compression and PPI.
UPDATE MultiLoad Utilizes the Teradata MultiLoad protocol to enable
job based table updates. This allows highly scalable
and parallel inserts and updates to an existing table.

EXPORT FastExport A producer operator that emulates the FastExport


utility
STREAM TPump Uses multiple sessions to perform DML transactions
in near real-time.
DataConnector N/A This operator emulates the Data Connector API.
Reads external data files, writes data to external data
files, reads an unspecified number of data files.

ODBC N/A Reads data from an ODBC Provider.

87 2012 WIPRO LTD | WWW.WIPRO.COM


TPT Wizard

Demonstrate Load and Unload using TPT Wizard


Explain the script generated by TPT Wizard
Discuss Limitations of TPT Wizard (using Help Menu)
Copy Script generated by TPT Wizard, Customize the script
and Run the Script thru Command Line Utility - TBUILD

88 2012 WIPRO LTD | WWW.WIPRO.COM


TPT Wizard (Contd.).

Demonstrate and Explain


Loading from various File
Format

89 2012 WIPRO LTD | WWW.WIPRO.COM


TPT Wizard (Contd.).

Demonstrate and Explain All Operator Types

90 2012 WIPRO LTD | WWW.WIPRO.COM


TPT Wizard (Contd.).

Demonstrate and Explain Exporting/Unloading to


various File Format

91 2012 WIPRO LTD | WWW.WIPRO.COM


TPT EasyLoader

TPT EasyLoader is a Unix like command-line interface to TPT for


loading data from a delimited flat file into a teradata table without
requiring to write TPT script

Explain TDLOAD options and Demonstrate loading from a CSV


File Refer Notes Page

tdload -f filename -h hostname -u username -t tablename


-d delimiter -j filename JobName

Monitor, Manage and Kill TPT EasyLoader Job

twbcmd JobName STATUS/PAUSE/RESUME

twbkill JobName
92 2012 WIPRO LTD | WWW.WIPRO.COM
TPT Utility Commands

TPT uses four basic utility commands to perform all of its


functions.

tbuild - used to run a TPT job

tlogview - used to read TPT logs, both public and private

twbkill - used to kill all TPT tasks within a job

twbstat - used to display TPT job status

93 2012 WIPRO LTD | WWW.WIPRO.COM


TPT Export Script

Refer Notes Page for Script

94 2012 WIPRO LTD | WWW.WIPRO.COM


95 2012 WIPRO LTD | WWW.WIPRO.COM
TPT Load Script

Refer Notes Page for Script

96 2012 WIPRO LTD | WWW.WIPRO.COM


97 2012 WIPRO LTD | WWW.WIPRO.COM
TPT Update Script

Refer Notes Page for Script

98 2012 WIPRO LTD | WWW.WIPRO.COM


99 2012 WIPRO LTD | WWW.WIPRO.COM
TPT Stream Script

Refer Notes Page for Script

10
2012 WIPRO LTD | WWW.WIPRO.COM
0
10
2012 WIPRO LTD | WWW.WIPRO.COM
1
Summary

In this lesson you learnt about:


TPT capabilities
Compare TPT with other tools
Load and Unload using TPT Wizard
Load using TPT EasyLoader
Using TPT Utility Commands
Prepare and run TPT scripts

10
2012 WIPRO LTD | WWW.WIPRO.COM
2
Compare Utilities

10
2012 WIPRO LTD | WWW.WIPRO.COM
3
Objectives

After completing this lesson, you will be able to:


Identify Strength and Limitation of each utility
Choose the Best utility for a given requirement

10
2012 WIPRO LTD | WWW.WIPRO.COM
4
Strengths and Limitations

BTEQ Fastexport Fastload Multiload TPump


DDL All No Limited All All
DML All SELECT INSERT I/P/D I/P/D
Multiple DML Yes Yes No Yes Yes
Multiple tables Yes Yes No Yes Yes
Multiple sessions Yes Yes Yes Yes Yes
Protocol Used SQL EXPORT FASTLOAD MULTILOAD TPump
Conditional Exp. Yes Yes No Yes Yes
Arithmetic Calc Yes Yes No Yes No
Data conversion Yes Yes 1/Column Yes Yes
Error files No No Yes Yes Yes
Error limits No No Yes Yes Yes
User routines No Yes Yes Yes Yes

10
2012 WIPRO LTD | WWW.WIPRO.COM
5
Choosing Utility
Utility Best for
TPT - All loading needs using single scripting language
- Interfacing with, MultiLoad, FastExport and TPump

FastExport - High performance initial table load

MultiLoad - High performance data maintenance (insert/update/delete/upsert)


on multiple empty/populated tables

TPump -Fast, scalable continuous data maintenance along with concurrent


queries (row hash lock) ETL tools and Custom programs thru API
- Combines functionality of FastLoad
- Real Time Update in Active Data Warehouse
BTEQ -Report formatting
- Ad hoc query tool
- Database Administration
-Small volume data movement

10
2012 WIPRO LTD | WWW.WIPRO.COM
6
Summary

In this lesson you learnt about:


Identifying Strength and Limitation of each utility
Choosing the Best utility for a given requirement

10
2012 WIPRO LTD | WWW.WIPRO.COM
7
Overview of other Tools

10
2012 WIPRO LTD | WWW.WIPRO.COM
8
Objectives

After completing this lesson, you will be able to:


Describe other System Management, Connectivity,
Interface and Storage Tools

10
2012 WIPRO LTD | WWW.WIPRO.COM
9
Teradata Manager

Teradata Manager is a production and performance monitoring


system that helps a DBA to monitor, control, and administer
one or more Teradata Database systems through a GUI.
Running on LAN-attached clients

Teradata Manager has a variety of tools and applications to


gather, manipulate, and analyze information about each
Teradata Database being administered.

11
2012 WIPRO LTD | WWW.WIPRO.COM
0
Storage Management Tools - ARC

Archive Recovery utility (ARC) to perform backup and restore


operations on tables, databases, and other objects.

There are several scenarios where restoring objects from


external media may be necessary:
Restoring non-Fallback tables after a disk failure.
Restoring tables that have been corrupted by batch processes
that may have left the data in an uncertain state.
Restoring tables, views, or macros that have been accidentally
dropped by the user.
Miscellaneous user errors resulting in damaged or lost database
objects.
Archive a single partition.

11
2012 WIPRO LTD | WWW.WIPRO.COM
1
ARC, ASF2

ARC interfaces to third party products to support backup and


restore capabilities.

With the ARC utility you can copy a table and restore it to
another Teradata Database. It is scalable and parallel, and can
run on a channel-attached client, network-attached client, or a
node.

ASF2 is GUI based tool for Archive / Recovery. ASF2 internally


calls ARC.

11
2012 WIPRO LTD | WWW.WIPRO.COM
2
ARC with Mainframe & LAN Client
ARC may be running on the
node or on the channel-
attached client, and will
backup data directly across
the channel into the
mainframe-attached tape
subsystem.

In a network-attached client
environment, ARC is used to
back up data, along with tape
management products:
NetVault (from BakBone
Software Inc.)
Veritas NetBackup from
Symantec Software

11
2012 WIPRO LTD | WWW.WIPRO.COM
3
Sample ARC Scripts

logon localtd/dbc,dbc;
archive data tables (tduser) (exclude tables (salgrade)),
release lock,
file=tduser;
logoff;

logon localtd/dbc,dbc; logon localtd/dbc,dbc;


analyze all, restore data tables (tduser.emp1),
display long, validate, release lock,
file=tduser; file= tduser;
logoff; logoff;

logon localtd/dbc,dbc;
copy data tables (tduser.emp2),
release lock,
file= tduser;
logoff;
11
2012 WIPRO LTD | WWW.WIPRO.COM
4
Connectivity Tools
Open Database Connectivity (ODBC) Driver delivers open
access to Teradata from Windows,Windows NT,UNIX,HP-
UX,Solaris-INTEL, Solaris - SPARC and AIX platforms.

Java Database Connectivity (JDBC) is an Application


Programming Interface (API) that allows platform independent
Java applications to access a DBMS using Structured Query
Language (SQL).

JDBC enables the development of web-based Teradata end


user tools that can access Teradata through a web server.

JDBC will also provide support for access to other commercial


databases.

11
2012 WIPRO LTD | WWW.WIPRO.COM
5
Interface Tools

CLI2 - allows you to write programs that submit SQL


statements to Teradata

WinCLI - provides a high performance, flexible interface to


Teradata from the Microsoft Windows environment

PreProcessor2 - allows embedded SQL statements in C and


COBOL application programs

Transparency Series/ Application Program Interface (TS/API) -


Enables IBM MVS/VM products that access either DB2 or
SQL/DS to transparently access Teradata

11
2012 WIPRO LTD | WWW.WIPRO.COM
6
Summary

In this lesson you learnt about:


Other System Management, Connectivity, Interface
and Storage Tools

11
2012 WIPRO LTD | WWW.WIPRO.COM
7
References

1. Tera-Tom on Teradata Utilities Book


2. Teradata 12 Database Administration (An Authorized Teradata
Certified Progessional Program Study Guide)

11
2012 WIPRO LTD | WWW.WIPRO.COM
8
Thank You

11
2012 WIPRO LTD | WWW.WIPRO.COM
9

You might also like