SESSIONS Command | Basic Teradata Query - SESSIONS - Basic Teradata Query

Basic Teradata® Query Reference

Product
Basic Teradata Query
Release Number
17.00
Published
December 2020
Language
English (United States)
Last Update
2020-12-12
dita:mapPath
zqt1544831938740.ditamap
dita:ditavalPath
obe1474387269547.ditaval
dita:id
B035-2414
lifecycle
previous
Product Category
Teradata Tools and Utilities

Purpose

This control enables users to specify the number of database sessions that BTEQ is to request be logged on when the LOGON command is next used.

Syntax



where the following is true:

n
The number of sessions that BTEQ is to run.

The maximum value of n is 200.

The number of sessions might be further limited by the number of sessions currently available from the database.

For information on session reserve, see “DISABLE SESSION RESERVE” and “ENABLE SESSION RESERVE” in Teradata® Director Program Reference, B035-2416.

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 SQL DATABASE statement. And use the REPEAT command when setting session specific attributes with the database, so that each session behaves the same.

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

The SESSIONS command is not valid in an SQL macro.

Example 1 – SESSIONS

To run three sessions concurrently that repeat the 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 2 – SESSIONS

Use the following syntax to specify the default database within an SQL statement 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 SQL INSERT statement. In this case, only one REPEAT command is required.

Example 3 – SESSIONS

To choose five database user 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.

Example 4 – SESSIONS

Use the REPEAT command to define session-specific attributes to all sessions:

.SET SESSIONS 4
.LOGON SIA1/KLD
.REPEAT 4
SET SESSION CHARACTER SET UNICODE PASS THROUGH ON;

In this case, the database's UPT feature is turned on for each session.