Teradata Basics
- Teradata - SubQueries
- Teradata - Joins
- Teradata - Primary Index
- Teradata - CASE & COALESCE
- Teradata - Aggregate Functions
- Teradata - Built-in Functions
- Teradata - Date/Time Functions
- Teradata - String Manipulation
- Teradata - SET Operators
- Logical & Conditional Operators
- Teradata - SELECT Statement
- Teradata - Data Manipulation
- Teradata - Tables
- Teradata - Data Types
- Teradata - Relational Concepts
- Teradata - Architecture
- Teradata - Installation
- Teradata - Introduction
Teradata Advanced
- Teradata - BTEQ
- Teradata - FastExport
- Teradata - MultiLoad
- Teradata - FastLoad
- Teradata - Performance Tuning
- Teradata - User Management
- Teradata - Data Protection
- Teradata - OLAP Functions
- Teradata - Partitioned Primary Index
- Teradata - JOIN Strategies
- Teradata - Stored Procedure
- Teradata - Macros
- Teradata - Views
- Teradata - Join Index
- Teradata - Hashing Algorithm
- Teradata - Explain
- Teradata - Compression
- Teradata - Statistics
- Teradata - Secondary Index
- Teradata - Space Concepts
- Teradata - Table Types
Teradata Useful Resources
- Teradata - Discussion
- Teradata - Useful Resources
- Teradata - Quick Guide
- Teradata - Questions & Answers
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Teradata - BTEQ
BTEQ utipty is a powerful utipty in Teradata that can be used in both batch and interactive mode. It can be used to run any DDL statement, DML statement, create Macros and stored procedures. BTEQ can be used to import data into Teradata tables from flat file and it can also be used to extract data from tables into files or reports.
BTEQ Terms
Following is the pst of terms commonly used in BTEQ scripts.
LOGON − Used to log into Teradata system.
ACTIVITYCOUNT − Returns the number of rows affected by the previous query.
ERRORCODE − Returns the status code of the previous query.
DATABASE − Sets the default database.
LABEL − Assigns a label to a set of SQL commands.
RUN FILE − Executes the query contained in a file.
GOTO − Transfers control to a label.
LOGOFF − Logs off from database and terminates all sessions.
IMPORT − Specifies the input file path.
EXPORT − Specifies the output file path and initiates the export.
Example
Following is a sample BTEQ script.
.LOGON 192.168.1.102/dbc,dbc; DATABASE tduser; CREATE TABLE employee_bkup ( EmployeeNo INTEGER, FirstName CHAR(30), LastName CHAR(30), DepartmentNo SMALLINT, NetPay INTEGER ) Unique Primary Index(EmployeeNo); .IF ERRORCODE <> 0 THEN .EXIT ERRORCODE; SELECT * FROM Employee Sample 1; .IF ACTIVITYCOUNT <> 0 THEN .GOTO InsertEmployee; DROP TABLE employee_bkup; .IF ERRORCODE <> 0 THEN .EXIT ERRORCODE; .LABEL InsertEmployee INSERT INTO employee_bkup SELECT a.EmployeeNo, a.FirstName, a.LastName, a.DepartmentNo, b.NetPay FROM Employee a INNER JOIN Salary b ON (a.EmployeeNo = b.EmployeeNo); .IF ERRORCODE <> 0 THEN .EXIT ERRORCODE; .LOGOFF;
The above script performs the following tasks.
Logs into Teradata System.
Sets the Default Database.
Creates a table called employee_bkup.
Selects one record from Employee table to check if the table has any records.
Drops employee_bkup table, if the table is empty.
Transfers the control to a Label InsertEmployee which inserts records into employee_bkup table
Checks ERRORCODE to make sure that the statement is successful, following each SQL statement.
ACTIVITYCOUNT returns number of records selected/impacted by the previous SQL query.