Академический Документы
Профессиональный Документы
Культура Документы
Simple BTEQ
After completing this module, you will be able to: Submit SQL to the Teradata RBDMS through BTEQ. Set session parameters to enable:
ANSI or Teradata transaction semantics SQL Flagger
BTEQ: Is a front-end utility for submitting SQL. Operates under all host systems and local area networks (LANs). May use mainframe terminals, PCs, or workstations. In batch mode, it obtains input from a host file (a "BTEQ script"). Can be used in interactive mode* Has import/export features* Has report writing features*
Response
BTEQ
TDP
PARSING ENGINE
AMP
AMP
AMP
AMP
DATA
DATA
DATA
DATA
Session Parameters
Session parameters must be established prior to logon. To view current parameters for transaction semantics and ANSI flagger, use the BTEQ command:
.SHOW CONTROL
There is no way to disable the Teradata RDBMS extensions, you can only flag them.
*** Logon successfully completed. *** Transaction Semantics are BTET. *** Character Set Name is 'ASCII'. *** Total elapsed time was 2 seconds.
SQLFLAG Example
.set session sqlflag entry; .logon xyz,xyz; sel date; *** Query completed. One row found. One column returned *** Total elapsed time was 1 second. sel date; $ *** SQL Warning 5836 Token is not an entry level ANSI Identifier or Keyword. sel date; $ *** SQL Warning 5818 Synonyms for Operators or Keywords are not ANSI. sel date; $ *** SQL Warning 5821 Built-in values DATE and TIME are not ANSI. sel date; $ *** SQL Warning 5804 A FROM clause is required in ANSI Query Specification. Date ----------97/01/20 .logoff .set session sqlflag none; .logon xyz,xyz; sel date; *** Query completed. One row found. One column returned. *** Total elapsed time was 1 second. Date ------97/01/20
SHOW CONTROL
.SHOW CONTROL;
Default Maximum Byte Count = 4096 Default Multiple Maximum Byte Count = 2048 Current Response Byte Count = 4096 Maximum number of sessions = 20 Maximum number of the request size = 32000 . . . EXPORT RESET IMPORT FIELD LOGON l5442/mj1 RUN [SET] ECHOREQ = ON [SET] ERRORLEVEL = ON [SET] FOLDLINE = OFF ALL [SET] FOOTING = NULL . . . [SET] RETCANCEL = OFF [SET] RETLIMIT = No Limit [SET] RETRY = ON [SET] RTITLE = NULL [SET] SECURITY = NONE [SET] SEPARATOR = two blanks [SET] SESSION CHARSET = ASCII [SET] SESSION SQLFLAG = ENTRY [SET] SESSION TRANSACTION = ANSI [SET] SESSIONS =1 [SET] SIDETITLES = OFF for the normal report. And, it is ON for results of WITH clause number: 1 2 3 4 5 6 7 8 9. [SET] SKIPDOUBLE = OFF ALL [SET] SKIPLINE = OFF ALL [SET] SUPPRESS = OFF ALL [SET] TDP = l5442 [SET] TITLEDASHES = ON for the normal report. And, it is ON for results of WITH clause number: 1 2 3 4 5 6 7 8 9. [SET] UNDERLINE = OFF ALL [SET] WIDTH = 75
-- Obtain a list of the department numbers and names from the -- department table. SELECT FROM .QUIT department_number ,department_name department;
ANSI compliant comments: Delimited by -- (2 dashes) and the end-of-line Cannot span multiple lines Teradata extension comments: Comments delimited by /* and */ May span multiple lines To execute the script: .run file=mod2exer.scr Results are shown on the next overhead
BTEQ -- Enter your DBC/SQL request or BTEQ command: -- Obtain a list of the department numbers and names from the -- department table. SELECT department_number ,department_name FROM department; *** Query completed. 9 rows found. 2 columns returned. *** Total elapsed time was 1 second. department_number department_name --------------------------- -----------------------------401 customer support <rest of result rows are not shown in this screen capture> BTEQ -- Enter your DBC/SQL request or BTEQ command: .QUIT *** You are now logged off from the DBC. *** Exiting BTEQ... *** RC (return code) = 0 # exit script done on Sat Feb 15 10:48:45 1997
BTEQ -- Enter your DBC/SQL request or BTEQ command: .quit *** You are now logged off from the DBC. *** Exiting BTEQ... *** RC (return code) = 8 # exit script done on Thu Oct 24 16:21:39 1996
Lab 2
See Lab 1_1, Lab 1_2, and Lab 1_3 pencil and paper workshops. Create these same reports on-line, using BTEQ scripts. Name these labs Lab 2_1, Lab 2_2, and Lab 2_3. You should have three separate reports when finished.
Note: Save the BTEQ script for Lab 2_1 as you will need it for Lab 3_4.
Lab 2Optional
Lab 2_4 Use BTEQ to submit your two reports from Lab 1_4. Observe the number of rows returned in your output, in each case. Which rows were eliminated due to the DISTINCT option?
Lab 2_5 Set the ANSI Flagger ON, then resubmit Lab2_1. What differences do you observe? Why?
Lab 2_6 a) Determine the default system session transaction mode. What command did you use? __________________________________ b) Set the session transaction mode to the opposite setting (ex., set it to ANSI if the system default is BTET), then verify the new setting.