SESSIONS - Basic Teradata Query

Basic Teradata Query Reference

Product
Basic Teradata Query
Release Number
15.00
Language
English (United States)
Last Update
2018-09-25
dita:id
B035-2414
lifecycle
previous
Product Category
Teradata Tools and Utilities

SESSIONS

Purpose  

Specifies the number of Teradata Database sessions that BTEQ is to request be logged on when the LOGON command is next used.

Syntax  

where:

 

Syntax Element

Specification

n

The number of sessions that BTEQ is to run.

The maximum value of n is 200.

If n is not specified, BTEQ sets SESSIONS to 1.

Note: The number of sessions might be further limited by the number of sessions currently available from Teradata Database.

For information on session reserve, refer to “DISABLE SESSION RESERVE” and “ENABLE SESSION RESERVE” in Teradata Director Program Reference.

Usage Notes  

Specify the SESSIONS command before specifying the LOGON command. The SESSIONS command is not accepted between the time that sessions are logged on and the time they are logged off. The most recent SESSIONS command is used for the number of sessions to log on with the next LOGON command.

If a SESSIONS command has not been used since invoking BTEQ, only one session is logged on.

To run more than one session concurrently, use the REPEAT or = command. When more than one session is used, the order in which requests are processed is not guaranteed. All sessions process identical requests, where only the data differs.

Running multiple sessions has the advantage of available sessions ready to retry a request if the in-use session becomes non-viable.

When running multiple sessions with the REPEAT command, supply the REPEAT command with the number of sessions before specifying the Teradata SQL DATABASE statement.

Use the SHOW CONTROLS command to determine the current value of n.

The SESSIONS command is not valid in a Teradata SQL macro.

Example  

To run three sessions concurrently that repeat the Teradata SQL INSERT request as many times as needed, specify:

   .SET SESSIONS 3
   .LOGON SIA1/KLD
   .REPEAT 3
   DATABASE Workforce;
   .REPEAT *
   USING num(SMALLINT)
   INSERT INTO Department (DeptNo) VALUES (:num) 
   ; 

The first REPEAT command specifies the default database for all three sessions. The second REPEAT command runs the three sessions until all the data is inserted. If the first REPEAT command is not specified, only the first session uses the Workforce database. The other two sessions do not have a database set.

Example  

Use the following syntax to specify the default database within the Teradata SQL command that specifies a table name:

   .SET SESSIONS 3
   .LOGON SIA1/KLD
   .REPEAT *
   USING num(SMALLINT)
   INSERT INTO Workforce.Department (DeptNo)
   VALUES (:num) 
   ;

In this example, the default database Workforce is supplied with the table name on the Teradata SQL INSERT statement. In this case, only one REPEAT command is required.

Example  

To choose five Teradata Database sessions, enter the following syntax:

   .SET SESSIONS 5
   .LOGON SIA1/KLD

BTEQ Response

After validating the logon, BTEQ displays:

   *** Logon successfully completed.    
   *** 5 sessions logged on.   
   *** Total elapsed time was 7 seconds.