Documente Academic
Documente Profesional
Documente Cultură
Agenda
BTEQ FastExport Fastload Multiload Tpump INMOD and OUTMOD processing
BTEQ
AN INTRODUCTION TO BTEQ
Why it is called BTEQ? Logging on to BTEQ Submitting SQL in BTEQs Interactive Mode Submitting SQL in BTEQs Batch Mode USING BTEQ CONDITIONAL LOGIC USING BTEQ TO EXPORT DATA BTEQ EXPORT EXAMPLE USING RECORD (DATA) MODE BTEQ EXPORT EXAMPLE USING FIELD (REPORT) MODE BTEQ IMPORT EXAMPLE BTEQ RETURN CODES BTEQ COMMANDS
BTEQ - Introduction
BTEQ is often referred to as the Basic TEradata Query tool Submit SQL in either a batch or interactive environment Tool for importing and exporting data Users can submit BTEQ jobs from batch scripts Error checking and conditional logic can be implemented Logging on to BTEQ: Interactive mode: .logon ipaddress(or)servername/username <password> Batch mode: .logon ip address(or)servername/username,password
BTEQ -
Type at command prompt: Logon with TDPID and USERNAME. .LOGON cdw/sql01; Then enter PASSWORD at the second prompt. Password: XXXXX Enter your BTEQ/SQL Request or BTEQ Command. BTEQ will respond and is waiting for a command. SELECT * FROM Employee_Table WHERE Dept_No = 400; *** Query Completed. 2 rows found. 5 Columns returned. *** Total elapsed time was 1 second. BTEQ displays information about the answer set.
BTEQ Mode
To submit a job in Batch mode : BTEQ < Scriptpath > logfilepath Sample bteq script: .LOGON 127.0.0.1/dbc,dbc /* Logon statement */
SELECT * FROM Employee_Table WHERE Dept_No = 400; .LOGOFF /* Logging off of Teradata */ Note: Instead having logon details in script,create a script to contain only logon credentials .RUN FILE =logondb.txt
BTEQ MODE
.RUN FILE =logondb.txt .EXPORT DATA FILE = C:\EMPS.TXT SELECT * FROM Employee_Table WHERE Dept_No = 400; .QUIT
Note: A period starting a line indicates a BTEQ command. If there is no period, then the command is an SQL command.
BTEQ MODE
BTEQ -
IMPORT Example
Bteq script for importing data with DATA mode option .SESSIONS 4 .LOGON 127.0.0.1/dbc,dbc; .IMPORT DATA FILE = C:\EMPS.TXT, SKIP = 2 .QUIET ON .REPEAT *
.QUIT
Return Code
00 02 04 08 12 .
Description
Job completed with no errors. User alert to log on to the Teradata DBS. Warning error. User error. Severe internal error.
BTEQ -Commands
BTEQ commands in Teradata are designed for flexibility Commands are classified in to four areas: Session Control Commands File Control Commands Sequence Control Commands Format Control Commands .
ABORT
DEFAULTS - Reset all BTEQ Format command options to their defaults. This will utilize the default configurations. EXIT - Immediately end the current session or sessions and exit BTEQ. - Abort any and all active running requests and transactions and EXIT BTEQ.
- Abort any and all active running requests and transactions, but do not exit BTEQ.
- End the current session or sessions, but do not exit BTEQ. - Starts a BTEQ Session. Every user, application, or utility must LOGON to Teradata to establish a session. - End the current session or sessions and exit BTEQ. Specifies the security level of messages between a network-attached system and the Teradata Database.
SESSIONS - Specifies the number of sessions to use with the next LOGON command. SESSION CHARSET - Specifies the name of a character set for the current session or sessions.
SESSION SQLFLAG - Specifies a disposition of warnings issued in response to violations of ANSI syntax. The SQL will still run, but a warning message will be provided. The four settings are FULL, INTERMEDIATE, ENTRY, and NONE. SESSION TRANSACTION - Specifies whether transaction boundaries are determined by Teradata SQL or ANSI SQL semantics. SHOW CONTROLS SHOW VERSIONS - Displays all of the BTEQ control command options currently configured. - Displays the BTEQ software release versions..
IMPORT - Open a file with a specific format to import information into Teradata. INDICDATA - One of multiple data mode options for data selected from Teradata. The modes are INDICDATA, FIELD, or RECORD MODE. OS - Execute an MS-DOS, PC-DOS, or UNIX command from inside BTEQ. QUIET - Limit BTEQ output displays to all error messages and request processing statistics. REPEAT - Submit the next request a certain amount of times RUN - Execute Teradata SQL requests and BTEQ commands directly from a specified run file.
GOTO - Skip all intervening commands and resume after branching forward to the specified label.
IFTHEN
Test a stated condition, and then resume processing based on the test results.
LABEL The GOTO command will always GO directly TO a particular line of code based on a label.
QUIT
These commands control the formatting for Teradata and present the data in a report mode to the screen or printer.
ECHOREQ - Enable the Echo required function in BTEQ returning a copy of each Teradata SQL request and BTEQ command to the standard output stream. FOLDLINE - Split or fold each line of a report into multiple lines. FOOTING - Specify a footer to appear at the bottom of every report page. NULL Specifies a character or string of characters to represent null values returned from Teradata. OMIT - Omit specific columns from a report. PAGEBREAK - Ejects a page whenever a specified column changes values. PAGELENGTH - Specifies the page length of printed reports based on lines per page. RECORDMODE - One of multiple data mode options for data selected from Teradata. (INDICDATA, FIELD, or RECORD). RETCANCEL - Cancel a request when the specified value of the RETLIMIT command option is exceeded. RETLIMIT - Specifies the maximum number of rows to be displayed or written from a Teradata SQL request. RETRY - Retry requests that fail under specific error conditions. RTITLE - Specify a header appearing at the top of all pages of a report. SEPARATOR - Specifies a character string or specific width of blank characters separating columns of a report. SIDETITLES - Place titles to the left or side of the report instead of on top. SKIPLINE - Inserts blank lines in a report when the value of a column changes specified values. SUPPRESS - Replace each and every consecutively repeated value with completely-blank character strings. TITLEDASHES -Display dash characters before each report line summarized by a WITH clause. UNDERLINE - Display a row of dash characters when the specified column changes values. WIDTH - Specifies the width of screen displays and printed reports, based on characters per line.