Вы находитесь на странице: 1из 6

Teradata and ANSI SQL Teradata SQL

To become an 'ANSI-standard' language, all vendors of SQL must become certified in ANSI (American National Standards Institute) standards by the NIST (National Institute of Standards and Technology), a government certification agency. There are three ANSI standards: ANSI SQL - 89 (SQL 1) ANSI SQL - 92 (SQL 2) ANSI SQL - 99 (SQL 3)

There are three levels of compliance within each level: ANSI SQL - 92 (SQL 2) Entry level Intermediate level Full level

ANSI SQL - 99 (SQL 3) Core Enhanced

Teradata SQL is an ANSI compliant product. Teradata has its own extensions to the language, as do most vendors. Teradata SQL is fully certified at the SQL92 Entry level, with some intermediate, some full and some SQL-99 Core features also implemented. As the Teradata database evolves, each major release is expected to move Teradata SQL closer to conformance with full SQL2, and including some features from the SQL3 standard.

Modes of Operation
Teradata SQL allows two different modes of session operation: ANSI mode Teradata (BTET) mode

Choice of mode affects: Transaction protocol behavior Case sensitivity defaults Collating sequences Data conversions Display functions

Be aware that the same SQL statement might perform differently in each mode based on the above considerations. Regardless of the mode you select, all syntax, whether or not ANSI compliant, is useable. No functionality is inhibited by choice of mode.

Setting the ANSI Flagger


There is an additional BTET session setting called the ANSI SQL Flag. It may be set to flag any non-ANSI syntax. It returns warning messages when non-ANSI syntax is encountered but it does not inhibit execution of the command. It is an informational setting only. The SQLFLAG may be set to any of the following three options: ENTRY - Flags syntax which does not conform to ANSI entry level requirements INTERMEDIATE - Flags syntax which does not conform to ANSI intermediate level requirements NONE - Sqlflag is disabled Teradata SQL is fully compliant at the ENTRY level and partially compliant at the INTERMEDIATE level. The SQL flagger must be enabled prior to logging on to a session: .SET SESSION SQLFLAG ENTRY

This setting flags all non-entry level ANSI syntax.

Example (Note: all user input commands are in red.) .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 5821 Built-in values DATE and TIME are not ANSI. sel date; $ *** SQL Warning 5804 A FROM clause is required in ANSI Query Specification. (Note that three warnings were generated because ANSI does not accept lowercase characters, abbreviations, or the DATE keyword. In spite of the warnings, the date is returned.) Date -------97/01/20

(Note that we must logoff in order to reset the ANSI Flagger.) .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

(Without the SQL Flagger, no warnings are generated)

Note: SQLFLAG may also be set when using Teradata front-end clients other than BTEQ, for example the Teradata Preprocessor (PP2) and the Call Level Interface (CLIv2).

BTEQ .SHOW CONTROL


The .SHOW CONTROL command shows all BTEQ reporting specifications, import and export features, as well as session parameters, including the SQL Flagger and the session Transaction mode: ANSI or BTET. Example [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] [SET] FOLDLINE = FOOTING = FORMAT = FORMCHAR = HEADING = INDICDATA = NOTIFY = NULL = OMIT = PAGEBREAK = PAGELENGTH = QUIET = RECORDMODE = RETCANCEL = RETLIMIT = RETRY = RTITLE = SECURITY = SEPARATOR = SESSION CHARSET = SESSION SQLFLAG = SESSION TRANSACTION SESSIONS = SIDETITLES = SKIPDOUBLE = SKIPLINE = OFF ALL NULL OFF OFF NULL OFF OFF ? OFF ALL OFF ALL 55 OFF OFF OFF No Limit ON NULL NONE two blanks ASCII NONE = BTET 1 OFF for the normal report. OFF ALL OFF ALL

[SET] SUPPRESS [SET] TDP [SET] TITLEDASHES And, it is 6 7 8 9. [SET] UNDERLINE [SET] WIDTH

= = = ON for

OFF ALL l5442 ON for the normal report. results of WITH clause number: 1 2 3 4 5

= OFF ALL = 75

On-Line Syntax HELP


HELP is available for SQL syntax problems. It can either display a menu of all available SQL commands and functions or provide syntax help on a particular SQL command.

Example
HELP 'SQL SELECT'; /* Provides syntax help for the SQL SELECT statement */ HELP 'SQL ALTER TABLE'; /* Provides syntax help for SQL ALTER TABLE statement */ HELP also provides syntax help for most Teradata client utilities as well as for SQL.

Example
HELP 'utilityname utilitycommand'; such as: HELP 'ARCHIVE Command-name'; HELP 'MULTILOAD command-name';

HELP Examples
HELP either generates a list of all available commands and functions, as in: HELP 'SQL'; *** Query completed. 35 rows found. One column returned. *** Total elapsed time was 1 second. On-Line Help (Partial Listing) -------------------------------------------------------------------

---DBS SQL COMMANDS: ABORT BEGIN TRANSACTION STATISTICS COMMIT DATABASE CREATE INDEX CREATE USER DELETE USER DROP DATABASE DROP TABLE STATISTICS ECHO TRANSACTION EXECUTE GRANT ALTER TABLE CHECKPOINT COMMENT CREATE MACRO CREATE VIEW DELETE DATABASE DROP INDEX DROP VIEW END LOGGING EXPLAIN GRANT LOGON BEGIN LOGGING COLLECT CREATE CREATE TABLE DATABASE DELETE DROP MACRO DROP END GIVE HELP

or, delivers the full syntax for any specified command, such as: HELP 'SQL UPDATE'; *** Query completed. 10 rows found. One column returned. *** Total elapsed time was 1 second. On-Line Help -------------------------------------------------------------------------UPD[ATE] tablename [ [AS] aname ] [ FROM tname [ [AS] aname] ] [... ,tname [ [AS] aname ] ] ; SET columnname = expr [ ... ,columnname = expr] [ WHERE condition ] [ ] ; [ ALL ]

Вам также может понравиться