Terminators | SQL Fundamentals | Teradata Vantage - 17.10 - Terminators - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Fundamentals

Advanced SQL Engine
Teradata Database
Release Number
Release Date
July 2021
Content Type
Programming Reference
Publication ID
English (United States)

The SEMICOLON is a Teradata SQL request terminator when it is the last nonblank character on an input line in BTEQ unless that line has a comment beginning with two dashes. In this case, the SEMICOLON request terminator must be on the line following the comment line.

A request is considered complete when either the “End of Text” character or the request terminator character is detected.

ANSI Compliance

The SEMICOLON as a request terminator is a Teradata extension to the ANSI/ISO SQL:2011 standard.

Example: Request Termination

On the following input line:

FROM Employee ;

the SEMICOLON terminates the single-statement request “SELECT * FROM Employee”.

BTEQ uses SEMICOLONs to terminate multistatement requests.

A request terminator is mandatory for request types that are:
  • In the body of a macro
  • Triggered action statements in a trigger definition
  • Entered using the BTEQ interface
  • Entered using other interfaces that require BTEQ

Example: Using a Request Terminator in the Body of a Macro

The following statement illustrates the use of a request terminator in the body of a macro.

CREATE MACRO Test_Pay (number (INTEGER),
                       name (VARCHAR(12)),
                       dept (INTEGER) AS
( INSERT INTO Payroll_Test (EmpNo, Name, DeptNo)
  VALUES (:number, :name, :dept) ;
  UPDATE DeptCount
  SET EmpCount = EmpCount + 1 ;
  FROM DeptCount ; )

Example: BTEQ Request

When entered through BTEQ, the entire CREATE MACRO statement must be terminated.

(number (INTEGER),
 name   (VARCHAR(12)),
 dept   (INTEGER) AS
(INSERT INTO Payroll_Test (EmpNo, Name, DeptNo)
 VALUES (:number, :name, :dept) ;
 UPDATE DeptCount
 SET EmpCount = EmpCount + 1 ;
 FROM DeptCount ; ) ;