Sunteți pe pagina 1din 22

The Teradata database is a massively parallel processing system running a "shared nothing" architecture.

The Database Management System is designed in such a way that all dimensions of its database system workload are considered scalable and predictable. (This would mean the number of users, data volume, breadth, and the complexity of queries.) These scalability features make it ideal for enterprise data warehousing. Interconnected with BYNET messaging fabric, Teradata is offered on Intel servers and use either Engenio or EMC disk arrays for storage. Typical O/S's used for Teradata are: NCR UNIX SVR4.2 MP-RAS, (which is a variant of System V UNIX), MS Windows 2000 and MS Windows Server 2003 or SUSE Linux Enterprise Server on 64-bit Intel server.

BTEQ
BTEQ is a Teradata native query tool for DBA and programmers. BTEQ (Basic TEradata Query) is a command-driven utility used to 1) access and manipulate data, and 2) format reports for both print and screen output. Like SQLPlus for the Oracle Database. It enables users on a workstation to easily access one or more Teradata Database systems for ad hoc queries, report generation, data movement (suitable for small volumes) and database administration.

All database requests in BTEQ are expressed in Teradata Structured Query Language (Teradata SQL). You can use Teradata SQL statements in BTEQ to: Define data create and modify data structures; Select data query a database; Manipulate data insert, delete, and update data; Control data define databases and users, establish access rights, and secure data; Create Teradata SQL macros store and execute sequences of Teradata SQL statements as a single operation.

BTEQ supports Teradata-specific SQL functions for doing complex analytical querying and data mining, such as: RANK - (Rankings); QUANTILE - (Quantiles); CSUM - (Cumulation); MAVG - (Moving Averages); MSUM - (Moving Sums); MDIFF - (Moving Differences); MLINREG - (Moving Linear Regression); ROLLUP - (One Dimension of Group); CUBE - (All Dimensions of Group); GROUPING SETS - (Restrict Group); GROUPING - (Distinguish NULL rows).

Noticeably, BTEQ supports the conditional logic (i.e., "IF..THEN..."). It is useful for batch mode export / import processing.

Operating Modes
BTEQ operates in two modes: interactive mode and batch mode. In interactive mode, you start a BTEQ session by entering BTEQ at the system prompt on your terminal or workstation, and submit commands to the database as needed. In batch mode, you prepare BTEQ scripts or macros, and then submit them to BTEQ from a scheduler for processing. A BTEQ script is a set of SQL statements and BTEQ commands saved in a file with the extension ".bteq"; however, it does not matter what file extension is used. The BTEQ script can be run using the following command (in UNIX or Windows): bteq < infle > outfile Here infile is the BTEQ script, and outfile is the output or log file.

BTEQ COMMANDS
This section is based on Teradata documentation[1], and for the detailed usage, please refer to Reference 1.

BTEQ Command Summary


BTEQ commands can be categorized into four functional groups, as described below: Session control Session control commands 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.

1. Commands for Session Control


COMMAND NAME ABORT

FUNCTION abort any active requests and transactions without exiting BTEQ. create or replace a Teradata stored procedure.

COMPILE DECIMALDIGITS

override the precision specified by a CLI System Parameter Block (SPB) max_decimal_returned entry, or if that entry does not exist,
to indicate what the precision should be for decimal values associated with subsequently issued SQL requests for non-fieldmode responses.

DEFAULTS

Resets BTEQ command options to the values that were set when BTEQ was first invoked. end the current sessions and exit BTEQ. abort any active requests and transactions and exit BTEQ; also called "HX". end the current sessions without exiting BTEQ. start a BTEQ session. bypass the warnings related to conventional LOGON command use.

EXIT HALT EXECUTION

LOGOFF LOGON LOGONPROMPT

QUIT SESSION CHARSET

end the current sessions and exit BTEQ. specify the name of a character set for the current session. override the buffer length specified in resp_buf_len. specify the disposition of warnings issued in response to violations of ANSI-compliant syntax. specify whether transaction boundaries are determined by Teradata SQL semantics or ANSI semantics. specify whether CLI double-buffering is used. specify the number of sessions to use with the next LOGON command. display the current configuration of the BTEQ control command options. display the BTEQ version number, module revision numbers, and linking date. specify the Teradata server for subsequent logons during the current session.

SESSION RESPBUFLEN SESSION SQLFLAG

SESSION TRANSACTION

SESSION TWORESPBUFS SESSIONS

SHOW CONTROLS

SHOW VERSIONS

TDP

2. Commands for File Control


COMMAND NAME
=

FUNCTION
Repeats the previous Teradata SQL request a specified number of times. enables users to specify whether the values of any fields associated with Identity Data are returned in response to a SQL Insert operation. executes a VM CMS command from within the BTEQ environment. Routes the standard error stream and the standard output stream to two files or devices for channelattached systems, or to one file or device for networkattached client systems. Specifies the name and format of an export file that BTEQ will use to store database information returned by a subsequent SQL SELECT statement. Enables suppression of the additional Page Advance ASA Carriage Control Character at the top of the EXPORT file in REPORT mode for MVS/VM BTEQ. aborts any active requests and transactions and exit BTEQ; also called "HX". Enables all of the page-oriented formatting commands, or disables them and centers the response from SQL SELECT statements, using the value of the WIDTH command option to determine the space available. Opens a channel- or network-attached system file, of the specified format, to provide data for USING modifiers of subsequent SQL statements. Specifies the mode of information returned from the Teradata Database in response to SQL SELECT

AUTOKEYRETRIEVE

CMS

ERROROUT

EXPORT

EXPORTEJECT

HALT EXECUTION

FORMAT

IMPORT

INDICDATA

statements.
INDICDATA and / or LARGEDATAMODE

specify the response mode, either Field mode, Indicator mode, Record mode, or Multipart Indicator Mode, for data selected from the Teradata Database.

LARGEDATAMODE

Enables use of Teradata Databases Multipart Indicator response mode for inline mode retrieval of Large Object (LOB) data. BTEQ limits the record size for exported files to approximately 64K (65473 for workstation builds and 64260 for mainframe builds).
If more than 64K is required, SET LARGEDATAMODE allows hex-dump style output (similar to RecordMode directed to standard output).

OS

executes an MS-DOS, PC-DOS, or UNIX command from within the BTEQ environment. Limits BTEQ output to errors and request processing statistics. BTEQ displays the results in a format that is suitable for performance testing. Returns data from SQL SELECT statements in clientoriented data representations rather than character format. submits the next request a specified number of times. executes Teradata SQL requests and BTEQ commands from a specified run file. executes an MVS TSO command from within the BTEQ environment.

QUIET

RECORDMODE

REPEAT RUN

TSO

3. Commands for Sequence Control


Use the following commands to control the sequence in which BTEQ executes commands: ABORT ERRORLEVEL EXIT GOTO HANG IF... THEN... LABEL MAXERROR QUIT REMARK REPEAT = For the commands not listed below, refer to the tables above.
COMMAND NAME
ERRORLEVEL GOTO

FUNCTION
Assigns severity levels to errors. Skips over all intervening BTEQ commands and SQL statements until a specified label is encountered, then resumes processing in sequence.

HANG IF... THEN... LABEL

Pauses BTEQ processing for a specified period of time. Tests the validity of the condition stated in the IF clause. Identifies the point at which BTEQ resumes processing, as specified in a previous GOTO command. Designates a maximum error severity level beyond which BTEQ terminates job processing.

MAXERROR

4. Format Control Commands


Use the following BTEQ commands to specify the way BTEQ presents information for screenoriented and printer/printer-file oriented output: DEFAULTS ECHOREQ EXPORT FOLDLINE FOOTING FORMAT HEADING IMPORT INDICDATA NULL OMIT PAGEBREAK PAGELENGTH QUIET RECORDMODE RETCANCEL RETLIMIT RETRY RTITLE SEPARATOR SHOW CONTROLS SIDETITLES SKIPDOUBLE SKIPLINE SUPPRESS TITLEDASHES UNDERLINE WIDTH For the commands not listed below, refer to the tables above.
COMMAND NAME
ECHOREQ

FUNCTION
Enables the echo required function that returns a copy of each Teradata SQL request and BTEQ command to the standard output stream. Splits (fold) each line of a report into two or more lines. Specifies a footer to appear at the bottom of every page of a report. Specifies a header to appear at the top of every page of a report. Specifies a character or character string to represent

FOLDLINE FOOTING

HEADING

NULL

null field values returned from the Teradata Database.


OMIT

Excludes specified columns returned from SQL SELECT statements. Ejects a page whenever the value for one or more specified columns changes. specify the page length of printed reports, in lines per page. cancel a request when the value specified by the RETLIMIT command ROWS option is exceeded. Specifies the maximum number of rows and/or columns displayed or written in response to a Teradata SQL request. resubmit requests that fail under certain error conditions. Specifies a header to appear at the top of every page of a report. Specifies a character string or width (in blank characters) to separate columns of a report. Position summary titles to the left of the summary lines in a report. insert two blank lines in a report whenever the value of a specified column changes. Inserts a blank line in a report whenever the value of a specified column changes. Replaces all consecutively repeated values with allblank character strings. Display a row of dash characters before each report line summarized by a WITH clause. Displays a row of dash characters whenever the value of a specified column changes. Specifies the width of screen displays and printed reports, in characters per line.

PAGEBREAK

PAGELENGTH

RETCANCEL

RETLIMIT

RETRY

RTITLE

SEPARATOR

SIDETITLES

SKIPDOUBLE

SKIPLINE

SUPPRESS

TITLEDASHES

UNDERLINE

WIDTH

BTEQ vs. FastExport and MultiLoad


BTEQ is similar to Teradata Fast Export and Teradata MultiLoad in exporting and importing. Yet, BTEQ is not a utility designed for bulk data movement. Firstly, Teradata export and load utilities are fully parallel. Therefore, in bulk exporting and loading scenarios, Teradata FastExport and MultiLoad are better performers than BTEQ because they are optimized to apply multiple rows in block-level operations. BTEQ can import and export small volumes of data to and from the Teradata Database. In this aspect, indeed, it is more efficient than Teradata SQL Assistant. However, for tables that have more than a few thousand rows (It depends), FastExport and MultiLoad are recommended for better efficiency. No wonder, "BTEQ on Unix/MVS (dunno about Windoze) is typically faster than FastExport until volumes get well into the millions, if not tens of millions, of rows."3 Secondly, FastExport and MultiLoad have full restart capability. This feature means that if a FastExport or MultiLoad job should be interrupted for some reason, it can be restarted again from the

last checkpoint, without having to start the job from the beginning. BTEQ does not support such features. Thirdly, MultiLoad can load multiple input files concurrently and work on up to five tables at a time, using multiple sessions. MultiLoad places a lock on on the destination table(s) to prevent user queries from getting inconsistent results before the data load or update is complete. In conclusion, for complex bulk-mode routines, FastExport and MultiLoad are preferred utilities; otherwise, BTEQ is a suitable choice.

FASTEXPORT COMMANDS
This section is based on Teradata documentation[1], and for the detailed usage, please refer to Reference 1.

FastExport Command Summary


The FastExport commands perform two types of activities: Support activities Support commands perform support activities to establish the FastExport sessions with the Teradata Database and define the operational support environment for Teradata FastExport. Established support environment options remain in effect until another support command changes them. Support commands are not directly involved in specifying a FastExport task; Task activities Task commands perform task activities to specify the actual processing of each FastExport task. 1. Teradata FastExport Commands for Support Activities:
COMMAND NAME ACCEPT

FUNCTION Allows the value of one or more utility variables to be accepted from either a file or an environment variable Specifies the form of the DATE data type specifications for the FastExport job Writes messages to the specified destination Introduces commands and statements that execute when a preceding IF condition is false Delimits the group of FastExport commands that were subject to previous IF or ELSE conditions Introduces a conditional expression whose value initiates execution of subsequent commands Disconnects all active sessions and terminates FastExport Specifies the LOGON string to be used in connecting all sessions established by FastExport Specifies a restart log table for the FastExport checkpoint information Identifies an alternate destination of FastExport output messages Invokes the specified external file as the current source of utility commands and Teradata SQL statements Assigns a data type and a value to a utility variable

DATEFORM

DISPLAY ELSE (see IF, ELSE, and ENDIF)

ENDIF (see IF, ELSE, and ENDIF)

IF (see IF, ELSE, and ENDIF)

LOGOFF

LOGON

LOGTABLE

ROUTE MESSAGES

RUN FILE

SET

SYSTEM

Suspends operation of FastExport and executes any valid local operating system command

2. Teradata FastExport Commands for Task Activities:


COMMAND NAME BEGIN EXPORT

FUNCTION Signifies the beginning of an export task and sets the specifications for the task sessions with the Teradata Database Signifies the end of an export task and initiates processing by the Teradata Database

END EXPORT

EXPORT

Provides: The client system destination and file format specifications for the export data retrieved from the Teradata Database; A generated MultiLoad script file that can be used later to reload the export data back into the Teradata Database.
Specifies a field of the input record that provides data values for the constraint parameters of the SELECT statement Specifies a field of the input record that will not be sent to the Teradata Database as part of the input record that provides data values for the constraint parameters of the SELECT statement Defines the client file that provides the USING data values for the SELECT statement Specifies, in conjunction with an immediately following sequence of FIELD and FILLER commands, the layout of the file that provides data values for the USING modifier of the SELECT statement

FIELD

FILLER

IMPORT

LAYOUT

Teradata SQL Statements in FastExport


FastExport supports a subset of Teradata SQL statements in order to define and manipulate the data stored in the Teradata Database. Consequently, other utilities do not have to be invoked to perform routine database maintenance functions before executing FastExport utility tasks. The Teradata SQL statements supported by Teradata FastExport are listed below:
COMMAND NAME ALTER TABLE

FUNCTION Changes the column configuration or options of an existing table Adds a checkpoint entry to a journal table Collects statistical data for one or more columns of a table Stores or retrieves comment string associated with a database object Creates a new database, macro, table, or view

CHECKPOINT COLLECT STATISTICS

COMMENT

CREATE DATABASE CREATE MACRO CREATE TABLE

CREATE VIEW
DATABASE

Specifies a new default database for the current session Removes rows from a table Removes all tables, views, and macros from a database Drops the definition for an empty database from the Data Dictionary Removes a table from the Teradata Database Transfers ownership of a database to another user Grants access privileges to a database object Inserts new rows to a table Changes the options of an existing database Changes the name of an existing table, view, or macro Redefines an existing macro or view

DELETE DELETE DATABASE DROP DATABASE

DROP TABLE GIVE GRANT INSERT MODIFY DATABASE RENAME

REPLACE MACRO
REPLACE VIEW REVOKE SET QUERY_BAND

Rescinds access privileges to a database object Allows a set of name-value pairs to be defined by the user and/or middle tier application so they can be customized to each applications unique needs Overrides the collation specification for the current session Changes the column values of an existing row in a table

SET SESSION COLLATION

UPDATE

Teradata FastLoad
"Teradata FastLoad" is a multi-sessioned parallel load utility for initial table load in bulk mode on a Teradata Database. This command-driven utility feeds only one table per job; to load more than one table, multiple jobs must be submitted. It loads data from: Disk or tape files on a channel-attached client system; Input files on a network-attached workstation; Special input module (INMOD) routines that select, validate, and preprocess input data; Any other device providing properly formatted source data.

OPERATING FEATURES
Interactive mode and Batch mode. Teradata FastLoad utilizes TCP/IP Protocol for all data transfer operations on networkattached workstations.

FASTLOAD COMMANDS

This section is based on Teradata documentation[1], and for the detailed usage, please refer to Reference 1.

FastLoad Command Summary


The FastLoad commands perform two types of activities: Session control Session control commands begin and end Teradata FastLoad sessions and provide online information about a particular Teradata FastLoad operation; Data handling Data handling commands establish and define a Teradata FastLoad operation. 1. Teradata FastLoad Commands for Session Control:
COMMAND NAME HELP HELP TABLE

FUNCTION Lists Teradata FastLoad commands and options Creates a list of field names that you can use with the INSERT statement Ends Teradata FastLoad sessions and terminates Teradata FastLoad Begins one or more Teradata FastLoad sessions Specifies a user exit or action to be performed when certain significant events occur Enters client operating system commands Specifies the number of Teradata FastLoad sessions logged on with a LOGON command and, optionally, the minimum number of sessions required to run the job Shows the current field/file definitions established by DEFINE commands Shows the current level of all Teradata FastLoad software modules Specifies the number of minutes that Teradata FastLoad pauses before retrying a logon operation Specifies the number of hours that Teradata FastLoad continues trying to log on when the maximum number of load jobs is already running on the Teradata Database

LOGOFF QUIT LOGON NOTIFY

OS SESSIONS

SHOW

SHOW SESSIONS

SLEEP

TENACITY

2. Teradata FastLoad Commands for Data Handling:


COMMAND NAME AXSMOD

FUNCTION Specifies the name and initialization string for a shared object file that loads data from a file on networkattached client systems

BEGIN LOADING

Identifies the tables used in the Teradata FastLoad operation and, optionally,
specifies when checkpoints are taken or if the user supplies indicator data

CLEAR QUIT

Cancels the current DEFINE command specifications

DATEFORM

Specifies the form of the DATE data type specifications for the Teradata FastLoad job Describes each field of an input data source record and specifies the name of the input data source or INMOD routine Informs the Teradata Database that all input data has been sent

DEFINE

END LOADING

ERRLIMIT

Limits the number of errors detected during the loading phase of a Teradata FastLoad job
Processing stops when the limit is reached.

RECORD

Specifies the number of a record in an input data source at which Teradata FastLoad begins to read data and/or the number of the last record to be read Invokes the specified external source as the current source of commands and statements

RUN

SET RECORD

Specifies that the input data records are either: Formatted Unformatted Binary Text Variable-length text
Note: The SET RECORD command applies only to network-attached systems.

SET SESSION CHARSET

Specifies which character set is in effect during a specific Teradata FastLoad invocation
Note: The SET SESSION CHARSET command applies only to networkattached systems.

Teradata SQL Statements in FastLoad


A subset of Teradata SQL statements can be used in Teradata FastLoad to define and manipulate the data stored in the Teradata Database. The Teradata SQL statements supported by Teradata FastLoad are listed below:
TERADATA SQL STATEMENT CREATE TABLE

FUNCTION Defines the columns, index, and other qualities of a table Changes the default database Deletes rows from a table Removes a table and all of its rows from a database Inserts rows into a table Sets query banding at the session level

DATABASE DELETE DROP TABLE INSERT SET QUERY_BANDING...FOR SESSION

Teradata MultiLoad
"Teradata MultiLoad" is a command-driven parallel load utility for high-volume batch maintenance on multiple tables and views of the Teradata Database. It is specially designed for high-speed batch creation and maintenance of large databases Teradata MultiLoad executes a series of MultiLoad commands and Teradata SQL statements written in a batch mode job script or interactively entered. The MultiLoad commands provide the session control and data handling specifications for the data transfer operations, and the Teradata SQL statements perform the actual maintenance functions on the Teradata RDBMS tables and views. A single MultiLoad job performs a number of different import and delete tasks on database tables and views: Each MultiLoad import task can do multiple data insert, update, and delete functions on up to five different tables or views; Each MultiLoad import task can have up to 100 DML steps; Each MultiLoad delete task can remove large numbers of rows from a single table. Teradata MultiLoad is characterized by its serialization feature. In certain scenarios, multiple changes are possible to occur to a single row in the same MultiLoad job. By using its serialization feature, Teradata MultiLoad automatically guarantees that the ordering of such operations is maintained correctly. If a MultiLoad job has only one import task, then Teradata FastLoad has to be chosen for it, since FastLoad will finish it much faster. However, the FastLoad utility works only on empty tables. A FastLoad job can not be used to: Insert additional data rows into an existing table; Update individual rows of existing tables; Delete individual rows from existing tables; Load data into multiple tables.

Teradata MultiLoad imports data from: Disk or tape files (using a custom Access Module) on a channel-attached client system; Input files on a network-attached workstation; Special input module (INMOD) routines that select, validate, and preprocess input data; Access modules; Any device providing properly formatted source data; The table or view in the database receiving the data can be any existing table or view for which the user has access privileges for the required maintenance tasks. MultiLoad command IMPORT has an optional parameter FORMAT, which is used to specify the format of the external data source. The format may be: FASTLOAD; BINARY; TEXT; UNFORMAT; VARTEXT.

MULTILOAD COMMANDS

This section is based on Teradata documentation[1], and for the detailed usage, please refer to Reference 1.
[edit]

MultiLoad Command Summary


The MultiLoad commands perform two types of activities: Support activities Support commands perform support activities to establish the MultiLoad sessions with the Teradata Database and define the operational support environment for Teradata MultiLoad. Established support environment options remain in effect until another support command changes them. Support commands do not specify a MultiLoad task; Task activities Task commands perform task activities to specify the actual processing of each MultiLoad task. 1. Teradata MultiLoad Commands for Support Activities:
COMMAND NAME ACCEPT

FUNCTION Allows the value of one or more utility variables to be accepted from either a file or an environment variable Specifies the form of the DATE data type specifications for the MultiLoad job Writes messages to the specified destination Introduces commands and statements that execute when a preceding IF condition is false Delimits the group of MultiLoad commands that were subject to previous IF or ELSE conditions Introduces a conditional expression whose value initiates execution of subsequent commands Disconnects all active sessions and terminates MultiLoad on the client system. Specifies the LOGON command string to be used in connecting all sessions established by MultiLoad. Identifies the table to be used to journal checkpoint information required for safe, automatic restart of MultiLoad when the client or Teradata Database system fails. Identifies the destination of output produced by MultiLoad support environment. Invokes the specified external file as the current source of utility commands and Teradata SQL statements Assigns a data type and a value to a utility variable Suspends operation of MultiLoad and executes any valid local operating system command

DATEFORM

DISPLAY ELSE (see IF, ELSE, and ENDIF)

ENDIF (see IF, ELSE, and ENDIF)

IF (see IF, ELSE, and ENDIF)

LOGOFF

LOGON

LOGTABLE

ROUTE MESSAGES

RUN FILE

SET SYSTEM

2. Teradata MultiLoad Commands for Task Activities:


COMMAND NAME BEGIN MLOAD and BEGIN DELETE MLOAD

FUNCTION

Specifies:


DML LABEL

The kind of MultiLoad task to be executed; The target tables in the Teradata Database; The parameters for executing the task.
Defines a label and error treatment options for a following group of DML statements. Indicates completion of MultiLoad command entries and initiates execution of the task. Used with the LAYOUT command to define a field of the data source record that is sent to the Teradata Database. Used with the LAYOUT command to define a field in the data source record that is not sent to the Teradata Database. Identifies the data source, the layout used to describe the data record, and optional conditions for performing DML operations. Introduces the record format of the data source to be used in the MultiLoad task. This command is followed by a sequence or combination of FIELD and TABLE commands. Supplies parameters to the LOGMECH command beyond those needed by the logon mechanism, such as userid and password, to successfully authenticate the user. Identifies the appropriate logon mechanism by name. Temporarily suspends the acquisition phase of a MultiLoad job.

END MLOAD

FIELD

FILLER

IMPORT

LAYOUT

LOGDATA

LOGMECH PAUSE ACQUISITION

TABLE

Used with the LAYOUT command to identify a table whose column names and data descriptions are used as the field names
and data descriptions of the data source records.

[edit]

Teradata SQL Statements in MultiLoad


MultiLoad supports a subset of Teradata SQL statements in order to define and manipulate the data stored in the Teradata Database. Consequently, other utilities do not have to be invoked to perform routine database maintenance functions before executing MultiLoad utility tasks. The Teradata SQL statements supported by Teradata MultiLoad are listed below:
COMMAND NAME ALTER TABLE

FUNCTION Changes the column configuration or options of an existing table Adds a checkpoint entry to a journal table Collects statistical data for one or more columns of a table Stores or retrieves comment string associated with a database object Creates a new database, macro, table, or view

CHECKPOINT COLLECT STATISTICS

COMMENT

CREATE DATABASE CREATE MACRO

CREATE TABLE CREATE VIEW


DATABASE

Specifies a new default database for the current session Removes rows from a table Removes all tables, views, and macros from a database Drops the definition for an empty database from the Data Dictionary Removes a table from the database Transfers ownership of a database to another user Grants access privileges to a database object Inserts new rows to a table Changes the options of an existing database

DELETE DELETE DATABASE DROP DATABASE

DROP TABLE GIVE GRANT INSERT MODIFY DATABASE RELEASE MLOAD

Removes the access locks from the target tables in the Teradata Database This inhibits any attempts to restart the MultiLoad job when a MultiLoad task has been suspended or aborted. Note: A RELEASE MLOAD statement must be entered from BTEQ. It cannot be entered from MultiLoad.
Changes the name of an existing table, view, or macro Redefines an existing macro or view

RENAME

REPLACE MACRO
REPLACE VIEW REVOKE SET QUERY_BAND

Rescinds access privileges to a database object Identifies type and source of query to determine prioritization of queries Overrides the collation specification for the current session Turns replication services on or off Changes the column values of an existing row in a table

SET SESSION COLLATION

SET SESSION OVERRIDE REPLICATION ON/OFF UPDATE

[edit]

Teradata SQL Statements in MultiLoad


MultiLoad supports a subset of Teradata SQL statements in order to define and manipulate the data stored in the Teradata Database. Consequently, other utilities do not have to be invoked to perform routine database maintenance functions before executing MultiLoad utility tasks. The Teradata SQL statements supported by Teradata MultiLoad are listed below:
COMMAND NAME ALTER TABLE

FUNCTION Changes the column configuration or options of an existing table Adds a checkpoint entry to a journal table

CHECKPOINT

COLLECT STATISTICS

Collects statistical data for one or more columns of a table Stores or retrieves comment string associated with a database object Creates a new database, macro, table, or view

COMMENT

CREATE DATABASE CREATE MACRO CREATE TABLE CREATE VIEW


DATABASE

Specifies a new default database for the current session Removes rows from a table Removes all tables, views, and macros from a database Drops the definition for an empty database from the Data Dictionary Removes a table from the database Transfers ownership of a database to another user Grants access privileges to a database object Inserts new rows to a table Changes the options of an existing database

DELETE DELETE DATABASE DROP DATABASE

DROP TABLE GIVE GRANT INSERT MODIFY DATABASE RELEASE MLOAD

Removes the access locks from the target tables in the Teradata Database This inhibits any attempts to restart the MultiLoad job when a MultiLoad task has been suspended or aborted. Note: A RELEASE MLOAD statement must be entered from BTEQ. It cannot be entered from MultiLoad.
Changes the name of an existing table, view, or macro Redefines an existing macro or view

RENAME

REPLACE MACRO
REPLACE VIEW REVOKE SET QUERY_BAND

Rescinds access privileges to a database object Identifies type and source of query to determine prioritization of queries Overrides the collation specification for the current session Turns replication services on or off Changes the column values of an existing row in a table

SET SESSION COLLATION

SET SESSION OVERRIDE REPLICATION ON/OFF UPDATE

Teradata TPump
TPump, short for "Teradata Parallel Data Pump," is a continuous data-loading utility used to move data into the Teradata Database without locking the affected tables. This parallel utility is featured by: 1) stream-mode loading and 2) its SQL-based, but not block-based, protocol.

OVERVIEW
With its stream-mode loading functionality, TPump is designed for loading near real-time data into the data warehouse to maintain fresh, accurate data for up-to-the-minute decision making. TPump can be used to insert, update, upsert and delete data in the Teradata Database, particularly for environments where batch windows are shrinking and data warehouse maintenance overlaps normal working hours. Unlike most other loading utilities, TPump uses row hash locks rather than table level locks. As a result, Teradata tables can be queried even while they are being updated by TPump. This also means that TPump can be stopped instantaneously. TPump uses standard Teradata SQL to achieve moderate to high data loading rates for the Teradata Database. Multiple sessions and multistatement requests are typically used to increase throughput. TPump is an alternative to Teradata MultiLoad for mixed workloads and near real-time data availability. It is more suitable for the low volume batch maintenance of large databases than MultiLoad. Instead of updating Teradata Databases overnight, or in batches throughout the day, TPump updates information in near real-time or real time, acquiring data from the client system with low processor utilization. This is realized through a stream-mode data feed into the data warehouse, rather than through the traditional batch updates. Stream-mode updates result in more accurate timely data. TPump has a dynamic throttling feature that enables it to run "all out" during batch windows, but within limits when it may affect other business applications using the database. Operators can define the number of statements executed per minute, or may alter throttling minute-by-minute, when needed.

MAIN ATTRIBUTES
Its setup does not require staging of data, intermediary files, or special hardware; Its operation is not affected by database restarts, dirty data, and network slowdowns. Its jobs restart without intervention; TPump accepts a variety of data forms from various data sources, including direct feeds from other databases. It has also the feature of data conversion capabilities. SQL statements and conditional logic can be used within TPump, making it unnecessary to write wrapper jobs.

OPERATING FEATURES
Operating Modes
TPump runs in the following operating modes: Interactive mode; Batch mode. In interactive mode, Teradata TPump uses terminal screen and keyboard as the standard output and input streams, involving the more or less continuous participation of the user. In batch mode, Teradata TPump processes data in discrete groups of previously scheduled operations, typically in a separate operation, rather than interactively or in real time..

TPUMP COMMANDS
This section is based on Teradata documentation.(See Reference 1.)

Syntax Notes
Each TPump command: Must begin on a new line; Must start with a period (.) character; Must end with a semicolon (;) character; May continue for as many lines as necessary, as long as it satisfies the beginning and ending requirements.

1. Teradata TPump Commands:


COMMAND
ACCEPT

FUNCTION
Accepts the data type and value of one or more utility variables from an external source. Indicates the start of a TPump task and specifies the parameters for executing the task. Lets you define the form of the DATE data type specifications for the TPump job. Writes messages to the specified destination. Defines a label and error treatment option for the Teradata SQL DML statement(s) following the DML command. INSERT, UPDATE, DELETE, and EXECUTE are the DML statement options. The ELSE command is followed by commands and statements that execute when the preceding IF command is false. Exits from the conditional expression IF or IF/ELSE command sequences. ENDIF is followed by commands and statements resuming the program. Indicates completion of TPump command entries and initiates the task. This is the last command of a TPump task. Defines a field of the data source record. Fields specified by this command are sent to the Teradata Database. This command is used with the LAYOUT command. Defines a field in the data source that is not sent to the Teradata Database. This command is used with the LAYOUT command. The IF command is followed by a conditional expression which, if true, executes commands and statements following the IF command. Identifies the data source, layout, and optional selection criteria to the client program. Specifies layout of the externally stored data records to be used in the TPump task. This command is used in conjunction with an immediately following sequence of FIELD, FILLER, and TABLE commands. Disconnects all active sessions and terminates execution of TPump on the client.

BEGIN LOAD

DATEFORM

DISPLAY DML (see IF, ELSE, and ENDIF)

ELSE

ENDIF

END LOAD

FIELD

FILLER

IF

IMPORT

LAYOUT

LOGOFF

LOGON

Establishes a Teradata SQL session on the Teradata Database, and specifies the LOGON string to be used in connecting all sessions required by subsequent functions. Identifies the table to be used for journaling checkpoint information required for safe, automatic restart of TPump in the event of a client or Teradata Database failure. Sets the utility variable &SYSJOBNAME with a job name of up to 16 characters. Establishes session partitions to transfer SQL requests to the Teradata Database. Identifies the destination of output produced by TPump. Invokes the specified external source as the current source of commands and statements. Assigns a data type and a value to a utility variable. Suspends TPump to issue commands to the local operating system.

LOGTABLE

NAME

PARTITION

ROUTE RUN FILE

SET SYSTEM

TABLE

Identifies a table whose column names and data descriptions are used as the names and data descriptions of the input record fields. Used in place of, or in addition to, the FIELD command. This command is used with the LAYOUT command.
Note: When UTF16 session character set is used, the TABLE command will generate a field of CHAR(2n) for the CHAR(n) typed column and a field of VARCHAR(2m) for the VARCHAR(m) typed column because each character in the column takes 2-byte storage when using UTF16 session character set.

2. SQL Statements
The undermentioned Teradata SQL statements supported by TPump require special considerations for use with TPump. They are used for loading purposes and for creating TPump macros.
STATEMENTS
DATABASE

DEFINITION
Changes the default database qualification for all DML statements. Removes specified rows from a table. Specifies a user-created (predefined) macro for execution. The macro named in this statement resides in the Teradata Database and specifies the type of DML statement (INSERT, UPDATE, or DELETE) being handled by the macro. Adds new rows to a table by directly specifying the row data to be inserted. Changes field values in existing rows of a table.

DELETE EXECUTE

INSERT

UPDATE Statement and Atomic Upsert

ITEQ
ITEQ, short for Interactive TEradata Query, is a utility used to interactively access and manipulate data from the Teradata Database in both the MVS/TSO and VM/CMS environments, and format reports for both print and screen output.

OVERVIEW
As part of the Teradata Tools and Utilities (TTU), ITEQ performs like the mainframe equivalent of Teradata SQL Assistant. It allows a user to: Enter Teradata SQL statements: A user can enter and execute a Teradata SQL statement at a terminal. If the result of statement execution is unsatisfactory, the user can conveniently modify the statement without re-entering it; View results: A user can browse through the result of a Teradata SQL statement, moving the screen horizontally or vertically over a result that exceeds the size of a single display; Format data and reports: A user can easily format the result of a query for display on a terminal screen, for printing on a hardcopy device, or storing on a disk file; Execute macros: A user can define and execute macros that contain one or several statements and ITEQ commands; Control terminal operation: A user can define the use of program function (PF) keys on the terminal keyboard and adjust the format of information displayed on the screen; Display and modify reference information so that the user can: Display Data Dictionary/Directory views; Modify and replace view and macro definitions; View and modify the last executed Teradata SQL statement; View ITEQ controls currently in effect.

OPERATING ENVIRONMENT
ITEQ operates on IBM (or IBM-compatible) processors that support the MVS/370 and/or the MVS/XA architecture. ITEQ operates under the following operating systems: MVS/TSO VM/CMS

External Loaders
Informatica basically used for data extracts and loads. Informatica has the ability to load data into Teradata and other databases, both by using an ODBC connection, and by building and Launching Teradata load utility scripts. The Teradata load and unload utilities are designed to load Massive amounts of data in a short amount of time. Teradata standalone load and unload utilities are fast, reliable tools that help you export large amounts of data from Teradata databases and load session target files into Teradata databases. Use a standalone load or unload utility when Power Center sessions extract or load large amounts of data. Standalone load and unload utilities are faster than Teradata relational connections because they load or extract data directly from a file or pipe rather than run SQL commands to load or extract the data. Informatica is a ETL tool when combined with Teradata, Teradata act as loading tool because with exceptional and speedy load and unload of basic nature of teradata.For example Teradata able to load 2 million records in less then 2 minutes.
Teradata External loader behavior: When you run a session that uses an external loader, the

Integration Service creates a control file and a target flat file. The control file contains information such as data format and loading instructions for the external loader. The control file has an extension of .ctl.

You can view the control file and the target flat file in the target file directory. The Integration Service waits for all external loading to complete before it performs post-session commands, runs external procedures, and sends post-session email. The Integration Service writes external loader initialization and completion messages in the session log. When you run a session, the Integration Service deletes and recreates the target file. The external loader uses the control file to load session output to the database Types of External Loaders associated with Teradata 1) MultiLoad External loaders 2) Tpump External loaders 3) Fast Load External loaders
MultiLoad: MultiLoad supports insert, update, delete, and upsert operations for up to Five target

tables. It can apply conditional logic to determine what updates to apply. Its Speed approaches that of Fast load. MultiLoad is limited to one input file. Tables being Multicoated are available for select access only.
Tpump: Tpump is generally used for low volume maintenance of large tables, and/or near real-time

maintenance. It does row-at-a-time processing using SQL, and is slower than Fast load and MultiLoad. A table being maintained by tpump is available for other updates while at the same time the tpump is running against the table. Tpump does not support multiple input files. Fast load:
Fast load inserts large volumes of data very rapidly into Teradata tables. It can load one table from multiple input files. The biggest restriction with Fast load is that the table being loaded must be empty. This is useful for initial loads, or loading tables that are emptied prior to scheduled loads. But it cant be used for incremental updates. Fast load will not load duplicate rows into a table, even if the table is created as a mustiest table. Completely duplicate input rows dont cause errors; they are simply dropped during the load process. A table being fast loaded is not available to users for queries.

When you run a session that uses an external loader, the Integration Service creates a control file and a target flat file. The control file contains information such as data format and loading instructions for the external loader. The control file has an extension of .ctl. You can view the control file and the target flat file in the target file directory. When you rerun a session, the Integration Service deletes and recreates the target file and ctl file. (There is no chance of restarting the script again from last check point) The Integration Service waits for all external loading to complete before it performs postsession commands, runs external procedures, and sends post-session email. The Integration Service writes external loader initialization and completion messages in the session log. The loader saves the log in the same directory as the target flat files. The default extension for external loader logs is .ldrlog. The behavior of the external loader depends on how you choose to load the data. You can load data to a named pipe or to a flat file. Named Pipe: The external loader starts to load data to the database as soon as the data appears in the pipe. The loader deletes the named pipe as soon as it completes the load. On UNIX, the Integration Service writes to a named pipe that is named after the configured target file name. On Windows, the Integration Service writes data to a named pipe using the specified format. Flat file: When you stage data to a flat file on Windows or UNIX, the Integration Service writes data to a flat file, which is named after the configured target file name. The external loader starts loading data to the target database after the Integration Service writes all the data to the target flat file. The external loader does not delete the target flat file after loading it to the database.

BYNET
BYNET, acronym for "BanYan NETwork," is a folded banyan switching network built upon the capacity of the YNET. It acts as a distributed multi-fabric inter-connect to link PEs, AMPs and nodes on a Massively Parallel Processing (MPP) system.

AMP

AMP, acronym for "Access Module Processor," is the type of vproc used to manage the database, handle file tasks and and manipulate the disk subsystem in the multi-tasking and possibly parallelprocessing environment of the Teradata Database

PE
PE, acronym for "Parsing Engine," is the type of vproc (Virtual Processor) for session control, task dispatching and SQL parsing in the multi-tasking and possibly parallel-processing environment of the Teradata Database.

Teradata PT
Teradata PT, short for "Teradata Parallel Transporter," is an integrated ETL suite for loading, retrieving, processing, and transferring data within the Teradata Database and between external databases and the Teradata Database.

VPROC
Vproc, acronym for "Virtual PROCessor," is a self-contained instance of the processor software on a Teradata platform (SMP platform or a node). Vprocs are the basic units of parallelism that make up the Teradata database server.

S-ar putea să vă placă și