359 29 1003KB
English Pages 326 Year 2003
Teradata® RDBMS SQL/Data Dictionary Quick Reference V2R5.0
B035-1510-122B February 2003
The product described in this book is a licensed product of NCR Corporation. BYNET is an NCR trademark registered in the U.S. Patent and Trademark Office. CICS, CICS/400, CICS/600, CICS/ESA, CICS/MVS, CICSPLEX, CICSVIEW, CICS/VSE, DB2, DFSMS/MVS, DFSMS/VM, IBM, NQS/MVS, OPERATING SYSTEM/2, OS/2, PS/2, MVS, QMS, RACF, SQL/400, VM/ESA, and VTAM are trademarks or registered trademarks of International Business Machines Corporation in the U. S. and other countries. DEC, DECNET, MICROVAX, VAX and VMS are registered trademarks of Digital Equipment Corporation. HEWLETT-PACKARD, HP, HP BRIO, HP BRIO PC, and HP-UX are registered trademarks of Hewlett-Packard Co. KBMS is a trademark of Trinzic Corporation. INTERTEST is a registered trademark of Computer Associates International, Inc. MICROSOFT, MS-DOS, MSN, The Microsoft Network, MULTIPLAN, SQLWINDOWS, WIN32, WINDOWS, WINDOWS 2000, and WINDOWS NT are trademarks or registered trademarks of Microsoft Corporation. SAS, SAS/C, SAS/CALC, SAS/CONNECT, and SAS/CPE are registered trademarks of SAS Institute Inc. SOLARIS, SPARC, SUN and SUN OS are trademarks of Sun Microsystems, Inc. TCP/IP protocol is a United States Department of Defense Standard ARPANET protocol. TERADATA and DBC/1012 are registered trademarks of NCR International, Inc. UNICODE is a trademark of Unicode, Inc. UNIX is a registered trademark of The Open Group. X and X/OPEN are registered trademarks of X/Open Company Limited. YNET is a trademark of NCR Corporation.THE INFORMATION CONTAINED IN THIS DOCUMENT IS PROVIDED ON AN “AS-IS” BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT APPLY TO YOU. IN NO EVENT WILL NCR CORPORATION (NCR) BE LIABLE FOR ANY INDIRECT, DIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS OR LOST SAVINGS, EVEN IF EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
The information contained in this document may contain references or cross references to features, functions, products, or services that are not announced or available in your country. Such references do not imply that NCR intends to announce such features, functions, products, or services in your country. Please consult your local NCR representative for those features, functions, products, or services available in your country. Information contained in this document may contain technical inaccuracies or typographical errors. Information may be changed or updated without notice. NCR may also make improvements or changes in the products or services described in this information at any time without notice. To maintain the quality of our products and services, we would like your comments on the accuracy, clarity, organization, and value of this document. Please e-mail: [email protected] or write: Information Engineering NCR Corporation 100 North Sepulveda Boulevard El Segundo, CA 90245-4361 U.S.A. Copyright © 1996-2003, NCR Corporation All Rights Reserved
Preface Supported Software Release This book supports Teradata RDBMS V2R5.0.
Changes to This Book This book includes the following changes to support the current release: Date
Description
February 2003
•
Replaced restricted word list in Appendix B with a cross-reference to Appendix A in Teradata RDBMS Release Summary.
December 2002
•
Updated existing syntax and added the following new syntax diagrams in Chapter 2 :
–
23 new diagrams to Arithmetic Operators and Functions/Trigonometric/Hyperbolic Functions
–
Two new diagrams in Built-In Functions
–
Two new diagrams in Ordered Analytical Functions
•
Updated existing syntax and added ten new diagrams in Chapter 3.
•
Updated existing syntax and added two new diagrams in Chapter 4.
•
Added a new Chapter 5 to include Query and Workload Analysis Statements.
•
Updated existing syntax and added one new diagrams in Chapter 7.
•
Updated existing syntax in Chapters 8 and 9. Added a new MERGE syntax diagram in Chapter 9.
•
Updated existing syntax and added one new diagram in Chapter 10.
•
Changed the term OLAP Functions to Ordered Analytical Functions.
•
Added a new chapter to contain syntax of the cursors and cursor control statements.
Teradata RDBMS SQL/Data Dictionary Quick Reference
i
Preface
Date
December 2002 (continued)
June 2001
September 2000
ii
Description
•
Added the following new views and new column fields in Chapter 12, Data Dictionary Views:
–
DBC.AllRoleRights
–
DBC.DBQLRules
–
DBC.Functions
–
DBC.ProfileInfo[X]
–
DBC.QryLog
–
DBC.QryLogObjects
–
DBC.QryLogSteps
–
DBC.QryLogSummary
–
DBC.RoleInfo[X]
–
DBC.UserRoleRights
•
Updated Appendix B with new reserved and restricted words.
•
Reorganized chapters.
•
Added the following new syntax diagrams:
–
7 new diagrams to Aggregate Functions in Chapter 2
–
3 new diagrams to Ordered Analytical Functions in Chapter 2
–
DROP HASH INDEX in Chapter 3
–
HELP HASH INDEX in Chapter 5
•
Added two new views to Chapter 10: “Data Dictionary Views”:
–
ColumnStats
–
IndexStats
•
Updated Appendix B with new reserved and restricted words.
•
Updated existing syntax diagrams
•
Updated Appendix A
Teradata RDBMS SQL/Data Dictionary Quick Reference
Preface
Date
June 2000
January 1999
Description
•
Updated the following information as required:
–
Existing syntax
–
SQL Keywords
•
Added new chapters containing syntax for the following types of statements:
–
Client-Server Connectivity
–
Stored Procedure Language
–
Target Level Emulation
•
Reorganized the quick reference by dividing, the SQL statement syntax into four functional categories:
–
SQL Data Definition Language
–
SQL Data Control Language
–
SQL Development Tools
–
SQL Data Manipulation Language
•
Added syntax for new SQL statements involving Dates and Times, Intervals, Triggers, Join Indexes, and dynamic statement reprioritization.
•
Revised existing syntax to accommodate expanded support for internationalization, temporary and volatile tables, and OLAP.
–
Added greatly expanded data types for Date, Time, and Interval data.
–
Added complete SQL function and expression syntax.
–
DR fixes and enhancement requests.
Teradata RDBMS SQL/Data Dictionary Quick Reference
iii
Preface About This Book
About This Book Purpose This book is a quick reference for the SQL dialect supported by the Teradata Relational Database Management System. The book is also a quick reference to the supported data description phrases for the Teradata RDBMS and the Data Dictionary.
Audience The audience for this quick reference is all users of Teradata SQL who need quick, non-detailed information about how to structure a SQL statement.
How This Book Is Organized This book contains the following chapters and appendixes: Chapter 1: “Data Types and Literals,” contains syntax for the Teradata SQL data handling, SQL data definition, control and manipulation, the SQL lexicon, and the foundations for the Teradata-supported international character sets. Chapter 2: “SQL Functions and Expressions,” describes the functions, operators, expressions, and predicates of Teradata SQL. Chapter 3: “SQL Data Definition Language Statement Syntax,” contains syntax for the Teradata SQL data definition language, which is used to create and delete or drop database objects. Chapter 4: “SQL Data Control Language Statement Syntax,” contains syntax for the Teradata SQL data control language, which is used to give, grant, and revoke access rights to SQL and monitor objects.
iv
Teradata RDBMS SQL/Data Dictionary Quick Reference
Preface About This Book
Chapter 5: “Query and Workload Analysis Statements,” contains syntax for the Teradata SQL query and workload analysis statements used to collect or analyze data demographics and statistics. Chapter 6: “SQL Help and Database Object Definition Tools: HELP and SHOW,” contains syntax for several useful tools for database administrators and designers, system administrators, and application developers. Chapter 7: “SQL Client-Server Connectivity Statements,” contains syntax for the individual SQL statements concerned with connecting and maintaining a client application to a Teradata RDBMS server. Chapter 8: “The SELECT Statement,” contains the syntax for the form, usage, and examples of the SELECT statement. It also contains syntax for the FROM clause and various SELECT statement clauses. Chapter 9: “SQL Data Manipulation Language Statement Syntax,” contains the syntax for Teradata SQL data manipulation language, which is used to query and update the database. Chapter 10: “SQL Stored Procedures,” contains the syntax for the statements for stored procedures, which provides a set of control and condition handling statements that make SQL a computationally complete programming language. Chapter 11: “Cursors and Cursor Control Statements,” contains syntax for the cursors and cursor control statements. Chapter 12: “Data Dictionary Views,” lists the views and columns of the Teradata Data Dictionary. Appendix A: “How to Read Syntax Diagrams,” provides information about the conventions used in syntax diagrams. Appendix B: “Restricted Words for V2R5.0,” describes Teradata reserved words, non-reserved words, those words reserved for future use, and SQL keywords.
Teradata RDBMS SQL/Data Dictionary Quick Reference
v
Preface About This Book
Prerequisites You should be familiar with basic computer technology, the Teradata relational database management system, and the Teradata SQL language. It may be helpful to review the following books: • • •
vi
Introduction to the Teradata RDBMS Teradata RDBMS SQL Reference Teradata RDBMS Data Dictionary
Teradata RDBMS SQL/Data Dictionary Quick Reference
Preface Technical Information on the Web
Technical Information on the Web The NCR home page (http://www.ncr.com) provides links to numerous sources of information about Teradata. Among the links provided are sites that deal with the following subjects: • • • • • • •
Contacting technical support Enrolling in customer education courses Ordering and downloading product documentation Accessing case studies of customer experiences with Teradata Accessing third party industry analyses of Teradata data warehousing products Accessing white papers Viewing or subscribing to various online periodicals
Teradata RDBMS SQL/Data Dictionary Quick Reference
vii
Preface Technical Information on the Web
viii
Teradata RDBMS SQL/Data Dictionary Quick Reference
Contents
Preface About This Book................................................................................................... iv Technical Information on the Web ................................................................... vii Chapter 1: Data Types and Literals Byte Data Types..................................................................................................1–2 BYTE ..............................................................................................................1–2 VARBYTE .....................................................................................................1–2 Character Data Types ........................................................................................1–3 CASESPECIFIC Phrase ...............................................................................1–3 CHARACTER Type.....................................................................................1–3 LONG VARCHAR Type ............................................................................1–3 UPPERCASE Phrase....................................................................................1–3 VARCHAR Type .........................................................................................1–4 Data Literals........................................................................................................1–5 CHARACTER Data Literals.......................................................................1–5 DATE Literals...............................................................................................1–5 DECIMAL Literals.......................................................................................1–5 FLOATING POINT Literals .......................................................................1–5 GRAPHIC Literals .......................................................................................1–5 Hexadecimal Literals ..................................................................................1–6 INTEGER Literals ........................................................................................1–6 INTERVAL DAY Literals ...........................................................................1–6 INTERVAL DAY TO HOUR Literals .......................................................1–7 Teradata RDBMS SQL/Data Dictionary Quick Reference
ix
Contents
INTERVAL DAY TO MINUTE Literals .................................................. 1–7 INTERVAL DAY TO SECOND Literals .................................................. 1–7 INTERVAL HOUR Literals ....................................................................... 1–7 INTERVAL HOUR TO MINUTE Literals ............................................... 1–7 INTERVAL HOUR TO SECOND Literals............................................... 1–8 INTERVAL MINUTE Literals ................................................................... 1–8 INTERVAL MINUTE TO SECOND Literals .......................................... 1–8 INTERVAL MONTH Literals ................................................................... 1–8 INTERVAL SECOND................................................................................. 1–8 INTERVAL YEAR Literals......................................................................... 1–9 INTERVAL YEAR TO MONTH Literals ................................................. 1–9 TIME Literals ............................................................................................... 1–9 TIMESTAMP Literals ................................................................................. 1–9 DateTime and Interval Data Types............................................................... 1–10 DATE Data Type....................................................................................... 1–10 INTERVAL DAY Data Type ................................................................... 1–10 INTERVAL DAY TO HOUR Data Type................................................ 1–10 INTERVAL DAY TO MINUTE Data Type ........................................... 1–10 INTERVAL DAY TO SECOND Data Type........................................... 1–10 INTERVAL HOUR Data Type ................................................................ 1–11 INTERVAL HOUR TO MINUTE Data Type ........................................ 1–11 INTERVAL HOUR TO SECOND Data Type ....................................... 1–11 INTERVAL MINUTE Data Type............................................................ 1–11 INTERVAL MINUTE TO SECOND Data Type ................................... 1–11 INTERVAL MONTH Data Type ............................................................ 1–12 INTERVAL SECOND Data Type ........................................................... 1–12 INTERVAL YEAR Data Type ................................................................. 1–12 INTERVAL YEAR TO MONTH Data Type.......................................... 1–12 TIME Data Type ........................................................................................ 1–12 TIME WITH TIME ZONE Data Type .................................................... 1–13 TIMESTAMP Data Type .......................................................................... 1–13 TIMESTAMP WITH TIME ZONE Data Type ...................................... 1–13 x
Teradata RDBMS SQL/Data Dictionary Quick Reference
Contents
Decimal/Numeric Data Types.......................................................................1–14 BYTEINT Data Type .................................................................................1–14 DECIMAL/NUMERIC Data Type..........................................................1–14 FLOAT/REAL/DOUBLE PRECISION Data Type ..............................1–14 INTEGER Data Type.................................................................................1–14 SMALLINT Data Type..............................................................................1–14 Default Value Control Phrases.......................................................................1–15 COMPRESS Phrase....................................................................................1–15 DEFAULT Phrase ......................................................................................1–15 NOT NULL Phrase....................................................................................1–15 WITH DEFAULT Phrase ..........................................................................1–15 Output Format Phrases ...................................................................................1–16 AS.................................................................................................................1–16 FORMAT.....................................................................................................1–16 NAMED ......................................................................................................1–16 TITLE...........................................................................................................1–16 Chapter 2: SQL Functions and Expressions Aggregate Functions..........................................................................................2–2 AVG ...............................................................................................................2–2 CORR.............................................................................................................2–2 COUNT .........................................................................................................2–2 COVAR_POP ...............................................................................................2–2 COVAR_SAMP ............................................................................................2–2 KURTOSIS ....................................................................................................2–3 MAX ..............................................................................................................2–3 MIN................................................................................................................2–3 REGR_AVGX ...............................................................................................2–3 REGR_AVGY ...............................................................................................2–3 REGR_COUNT ............................................................................................2–3 Teradata RDBMS SQL/Data Dictionary Quick Reference
xi
Contents
REGR_INTERCEPT .................................................................................... 2–4 REGR_R2...................................................................................................... 2–4 REGR_SLOPE .............................................................................................. 2–4 REGR_SXX ................................................................................................... 2–4 REGR_SXY ................................................................................................... 2–4 REGR_SYY ................................................................................................... 2–4 SKEW ............................................................................................................ 2–5 STDDEV_POP ............................................................................................. 2–5 STDDEV_SAMP.......................................................................................... 2–5 SUM .............................................................................................................. 2–5 VAR_POP..................................................................................................... 2–5 VAR_SAMP ................................................................................................. 2–5 Arithmetic Operators and Functions/Trigonometric/ Hyperbolic Functions........................................................................................ 2–6 Arithmetic Operators ................................................................................. 2–6 ABS................................................................................................................ 2–7 ACOS ............................................................................................................ 2–7 ACOSH......................................................................................................... 2–7 ASIN ............................................................................................................. 2–7 ASINH .......................................................................................................... 2–8 ATAN ........................................................................................................... 2–8 ATAN2 ......................................................................................................... 2–8 ATANH ........................................................................................................ 2–9 CASE_N........................................................................................................ 2–9 COS ............................................................................................................... 2–9 COSH .......................................................................................................... 2–10 EXP.............................................................................................................. 2–10 LN................................................................................................................ 2–10 LOG............................................................................................................. 2–10 NULLIFZERO............................................................................................ 2–11 RANDOM .................................................................................................. 2–11 RANGE_N ................................................................................................. 2–12 xii
Teradata RDBMS SQL/Data Dictionary Quick Reference
Contents
SIN ...............................................................................................................2–13 SINH ............................................................................................................2–13 SQRT............................................................................................................2–13 TAN .............................................................................................................2–14 TANH..........................................................................................................2–14 WIDTH_BUCKET......................................................................................2–14 ZEROIFNULL ............................................................................................2–14 Attribute Functions..........................................................................................2–15 BYTES ..........................................................................................................2–15 CHARACTERS ..........................................................................................2–15 CHARACTER_LENGTH .........................................................................2–15 FORMAT.....................................................................................................2–15 MCHARACTERS.......................................................................................2–15 OCTET_LENGTH......................................................................................2–16 TYPE ............................................................................................................2–16 Built-In Functions.............................................................................................2–17 ACCOUNT .................................................................................................2–17 CURRENT_DATE .....................................................................................2–17 CURRENT_TIME ......................................................................................2–17 CURRENT_TIMESTAMP.........................................................................2–17 DATABASE ................................................................................................2–17 DATE ...........................................................................................................2–18 PROFILE .....................................................................................................2–18 ROLE ...........................................................................................................2–18 SESSION .....................................................................................................2–18 TIME ............................................................................................................2–18 USER............................................................................................................2–18 CASE Expressions............................................................................................2–19 COALESCE Expression ............................................................................2–20 NULLIF Expression...................................................................................2–20 Comparison Operators....................................................................................2–21
Teradata RDBMS SQL/Data Dictionary Quick Reference
xiii
Contents
Data Type Conversions .................................................................................. 2–23 CAST ........................................................................................................... 2–23 Teradata Conversion Syntax ................................................................... 2–23 DateTime and Interval Functions and Expressions.................................... 2–24 Arithmetic Operators and Result Types................................................ 2–24 ANSI DateTime Expressions ................................................................... 2–25 ANSI Interval Expressions ...................................................................... 2–25 ADD_MONTHS ........................................................................................ 2–26 EXTRACT................................................................................................... 2–27 Hash-Related Functions ................................................................................. 2–28 HASHAMP ................................................................................................ 2–28 HASHBAKAMP........................................................................................ 2–28 HASHBUCKET ......................................................................................... 2–28 HASHROW................................................................................................ 2–29 Logical Predicates............................................................................................ 2–30 ANY/ALL/SOME Subquery Syntax..................................................... 2–30 BETWEEN/NOT BETWEEN .................................................................. 2–30 EXISTS/NOT EXISTS............................................................................... 2–30 IN/NOT IN................................................................................................ 2–31 IS NULL/IS NOT NULL ......................................................................... 2–31 LIKE ............................................................................................................ 2–32 OVERLAPS ................................................................................................ 2–32 Ordered Analytical Functions ....................................................................... 2–33 AVG ............................................................................................................ 2–33 COUNT ...................................................................................................... 2–34 CSUM.......................................................................................................... 2–35 MAVG......................................................................................................... 2–35 MAX............................................................................................................ 2–36 MDIFF......................................................................................................... 2–37 MIN ............................................................................................................. 2–38 MLINREG .................................................................................................. 2–39 MSUM......................................................................................................... 2–39 xiv
Teradata RDBMS SQL/Data Dictionary Quick Reference
Contents
PERCENT_RANK .....................................................................................2–39 QUANTILE.................................................................................................2–39 RANK ..........................................................................................................2–39 ROW_NUMBER ........................................................................................2–40 SUM .............................................................................................................2–41 Set Operators ....................................................................................................2–42 INTERSECT Operator...............................................................................2–43 MINUS/EXCEPT Operator......................................................................2–43 UNION Operator.......................................................................................2–44 String Functions ...............................................................................................2–45 CHAR2HEXINT ........................................................................................2–45 Concatenation Operator ...........................................................................2–45 INDEX .........................................................................................................2–45 LOWER .......................................................................................................2–45 POSITION...................................................................................................2–46 SOUNDEX ..................................................................................................2–46 SUBSTRING/SUBSTR ..............................................................................2–46 TRANSLATE ..............................................................................................2–46 TRANSLATE_CHK...................................................................................2–47 TRIM............................................................................................................2–47 UPPER .........................................................................................................2–47 VARGRAPHIC...........................................................................................2–47 Chapter 3: SQL Data Definition Language Statement Syntax ALTER PROCEDURE........................................................................................3–2 ALTER TABLE....................................................................................................3–3 Basic Table Parameters Modification Syntax ..........................................3–3 Primary Index Modification Syntax..........................................................3–5 Partitioned Primary Index Revalidation Syntax .....................................3–6 ALTER TRIGGER...............................................................................................3–7 Teradata RDBMS SQL/Data Dictionary Quick Reference
xv
Contents
BEGIN LOGGING ............................................................................................. 3–8 COMMENT ........................................................................................................ 3–9 CREATE DATABASE ..................................................................................... 3–10 CREATE HASH INDEX ................................................................................. 3–11 CREATE INDEX .............................................................................................. 3–12 CREATE JOIN INDEX .................................................................................... 3–13 Multitable Syntax ...................................................................................... 3–13 Single-Table Syntax .................................................................................. 3–15 CREATE/REPLACE MACRO....................................................................... 3–17 CREATE/REPLACE PROCEDURE ............................................................. 3–18 CREATE PROFILE .......................................................................................... 3–22 CREATE ROLE ................................................................................................ 3–23 CREATE TABLE .............................................................................................. 3–24 Create Table Syntax .................................................................................. 3–24 Copy Table Syntax .................................................................................... 3–27 CREATE TRIGGER REPLACE TRIGGER ................................................................................. 3–29 CREATE USER................................................................................................. 3–30 CREATE/REPLACE VIEW ........................................................................... 3–31 DATABASE ...................................................................................................... 3–32 DELETE DATABASE DELETE USER ........................................................................................... 3–33 DROP DATABASE ......................................................................................... 3–34 DROP HASH INDEX...................................................................................... 3–35 DROP INDEX................................................................................................... 3–36 DROP JOIN INDEX......................................................................................... 3–37 DROP MACRO DROP PROCEDURE DROP TABLE DROP TRIGGER DROP VIEW .............................................................................................. 3–38 DROP PROFILE ............................................................................................... 3–39
xvi
Teradata RDBMS SQL/Data Dictionary Quick Reference
Contents
DROP ROLE......................................................................................................3–40 DROP USER ......................................................................................................3–41 END LOGGING ...............................................................................................3–42 MODIFY DATABASE .....................................................................................3–43 MODIFY PROFILE...........................................................................................3–44 MODIFY USER .................................................................................................3–45 RENAME MACRO RENAME PROCEDURE RENAME TABLE RENAME VIEW RENAME TRIGGER..................................................................................3–46 SET ROLE..........................................................................................................3–47 SET SESSION ....................................................................................................3–48 Set Session Syntax......................................................................................3–48 Set Session Collation .................................................................................3–48 Set Session Account...................................................................................3–48 Set Session Dateform.................................................................................3–49 Set Session Database .................................................................................3–49 SET TIME ZONE ..............................................................................................3–50 Chapter 4: SQL Data Control Language Statement Syntax GIVE.....................................................................................................................4–2 GRANT ................................................................................................................4–3 Role Form......................................................................................................4–4 GRANT LOGON................................................................................................4–5 REVOKE ..............................................................................................................4–6 Role Form......................................................................................................4–7 REVOKE LOGON ..............................................................................................4–8
Teradata RDBMS SQL/Data Dictionary Quick Reference
xvii
Contents
Chapter 5: Query and Workload Analysis Statements BEGIN QUERY LOGGING.............................................................................. 5–2 COLLECT DEMOGRAPHICS ......................................................................... 5–3 COLLECT STATISTICS .................................................................................... 5–4 CREATE INDEX Syntax............................................................................. 5–4 COLLECT STATISTICS (QCD Form)............................................................. 5–5 DROP STATISTICS (Optimizer Form) ........................................................... 5–6 DROP STATISTICS (QCD Form) .................................................................... 5–8 DUMP EXPLAIN............................................................................................... 5–9 END QUERY LOGGING................................................................................ 5–10 INITIATE INDEX ANALYSIS ....................................................................... 5–11 INSERT EXPLAIN........................................................................................... 5–12 RESTART INDEX ANALYSIS ....................................................................... 5–13 DIAGNOSTIC DUMP COSTS ....................................................................... 5–14 DIAGNOSTIC DUMP SAMPLES ................................................................. 5–15 DIAGNOSTIC HELP COSTS......................................................................... 5–16 DIAGNOSTIC HELP SAMPLES ................................................................... 5–17 DIAGNOSTIC SET COSTS ............................................................................ 5–18 DIAGNOSTIC SET SAMPLES....................................................................... 5–19 General Syntax .......................................................................................... 5–19 Disable All Samples Syntax..................................................................... 5–19 DIAGNOSTIC “Validate Index” ................................................................... 5–20 Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP ................................................................................................................... 6–2 HELP (Online Form) ......................................................................................... 6–3 HELP COLUMN................................................................................................ 6–4 HELP CONSTRAINT........................................................................................ 6–5 xviii
Teradata RDBMS SQL/Data Dictionary Quick Reference
Contents
HELP DATABASE HELP USER ..................................................................................................6–6 HELP HASH INDEX .........................................................................................6–7 HELP INDEX ......................................................................................................6–8 HELP JOIN INDEX ............................................................................................6–9 HELP MACRO HELP TABLE HELP VIEW................................................................................................6–10 HELP PROCEDURE ........................................................................................6–11 HELP SESSION ................................................................................................6–12 HELP STATISTICS (Optimizer Form) ..........................................................6–13 HELP STATISTICS (QCD Form) ...................................................................6–14 HELP TRIGGER ...............................................................................................6–15 HELP VOLATILE TABLE...............................................................................6–16 SHOW ................................................................................................................6–17 SHOW JOIN INDEX SHOW MACRO SHOW PROCEDURE SHOW TABLE SHOW TRIGGER SHOW VIEW..............................................................................................6–18 Chapter 7: SQL Client-Server Connectivity Statements CONNECT ..........................................................................................................7–2 GET CRASH........................................................................................................7–3 LOGOFF ..............................................................................................................7–4 LOGON ...............................................................................................................7–5 SET BUFFERSIZE...............................................................................................7–6 SET CHARSET....................................................................................................7–7 SET CONNECTION ..........................................................................................7–8 SET CRASH.........................................................................................................7–9 Teradata RDBMS SQL/Data Dictionary Quick Reference
xix
Contents
Chapter 8: The SELECT Statement SELECT ............................................................................................................... 8–2 SELECT INTO .................................................................................................... 8–5 Embedded SQL Form................................................................................. 8–5 Stored Procedures Form ............................................................................ 8–5 DISTINCT and ALL Options .................................................................... 8–6 FROM Clause............................................................................................... 8–6 WHERE Clause ........................................................................................... 8–6 Subqueries in Search Conditions .................................................................... 8–7 Clauses ................................................................................................................ 8–8 SAMPLEID Expression .............................................................................. 8–9 Chapter 9: SQL Data Manipulation Language Statement Syntax ABORT ................................................................................................................ 9–2 ASYNC Statement Modifier............................................................................. 9–3 BEGIN DECLARE SECTION........................................................................... 9–4 BEGIN TRANSACTION .................................................................................. 9–5 CALL ................................................................................................................... 9–6 CHECKPOINT ................................................................................................... 9–7 COMMENT ........................................................................................................ 9–8 COMMIT............................................................................................................. 9–9 DATABASE ...................................................................................................... 9–10 DECLARE STATEMENT ............................................................................... 9–11 DECLARE TABLE ........................................................................................... 9–12 DELETE............................................................................................................. 9–13 DESCRIBE......................................................................................................... 9–15 ECHO ................................................................................................................ 9–16 END DECLARE SECTION ............................................................................ 9–17 xx
Teradata RDBMS SQL/Data Dictionary Quick Reference
Contents
END-EXEC Statement Terminator ................................................................9–18 END TRANSACTION.....................................................................................9–19 EXEC ..................................................................................................................9–20 EXEC SQL Statement Prefix ...........................................................................9–21 EXECUTE ..........................................................................................................9–22 EXECUTE IMMEDIATE .................................................................................9–23 EXPLAIN Modifier ..........................................................................................9–24 INCLUDE ..........................................................................................................9–25 INSERT ..............................................................................................................9–26 LOCKING Modifier .........................................................................................9–27 MERGE ..............................................................................................................9–28 PREPARE ..........................................................................................................9–29 ROLLBACK.......................................................................................................9–30 TEST ...................................................................................................................9–31 UPDATE ............................................................................................................9–32 USING Row Descriptor...................................................................................9–34 WAIT..................................................................................................................9–35 WHENEVER .....................................................................................................9–36 Chapter 10: SQL Stored Procedures BEGIN - END Statement .................................................................................10–2 CASE ..................................................................................................................10–3 DECLARE .........................................................................................................10–4 DECLARE HANDLER ....................................................................................10–5 FOR.....................................................................................................................10–6 IF .........................................................................................................................10–7 ITERATE............................................................................................................10–8 LEAVE ...............................................................................................................10–9 LOOP ...............................................................................................................10–10 REPEAT ...........................................................................................................10–11 Teradata RDBMS SQL/Data Dictionary Quick Reference
xxi
Contents
SET ................................................................................................................... 10–12 WHILE ............................................................................................................ 10–13 Chapter 11: Cursors and Cursor Control Statements CLOSE ............................................................................................................... 11–2 DECLARE CURSOR ....................................................................................... 11–3 Dynamic SQL Form .................................................................................. 11–3 Macro Form................................................................................................ 11–3 Request Form............................................................................................. 11–3 Selection Form ........................................................................................... 11–3 Stored Procedures Form .......................................................................... 11–4 FETCH............................................................................................................... 11–5 Embedded SQL Form............................................................................... 11–5 Stored Procedures Form .......................................................................... 11–5 OPEN................................................................................................................. 11–6 Embedded SQL Form............................................................................... 11–6 Stored Procedures Form .......................................................................... 11–6 POSITION......................................................................................................... 11–7 REWIND ........................................................................................................... 11–8 Chapter 12: Data Dictionary Views View Definitions .............................................................................................. 12–2 DBC.AccessLog ......................................................................................... 12–3 DBC.AccLogRules..................................................................................... 12–4 DBC.AccLogRules (continued) ............................................................... 12–5 DBC.AccountInfo[X]................................................................................. 12–6 DBC.AllRights ........................................................................................... 12–6 DBC.AllRoleRights ................................................................................... 12–7
xxii
Teradata RDBMS SQL/Data Dictionary Quick Reference
Contents
DBC.AllSpace[X]........................................................................................12–8 DBC.AllTempTables[X] ............................................................................12–8 DBC.All_RI_Children ...............................................................................12–9 DBC.All_RI_Parents ................................................................................12–10 DBC.AMPUsage ......................................................................................12–10 DBC.Association ......................................................................................12–11 DBC.CharSets...........................................................................................12–11 DBC.CharTranslations ............................................................................12–12 DBC.Children[X]......................................................................................12–12 DBC.Collations.........................................................................................12–12 DBC.Columns[X] .....................................................................................12–13 DBC.ColumnStats....................................................................................12–14 DBC.Databases[X] ...................................................................................12–15 DBC.Databases2.......................................................................................12–15 DBC.Database_Default_Journals[X] .....................................................12–16 DBC.DBCInfo ...........................................................................................12–16 DBC.DBQLRules......................................................................................12–17 DBC.DeleteAccessLog[X] .......................................................................12–17 DBC.DeleteOldInDoubt..........................................................................12–18 DBC.DiskSpace[X] ...................................................................................12–19 DBC.Events[X] .........................................................................................12–20 DBC.Events_Configuration[X] ..............................................................12–21 DBC.Events_Media[X] ............................................................................12–21 DBC.Functions .........................................................................................12–22 DBC.Hardware_Event_Log ...................................................................12–23 DBC.HostsInfo .........................................................................................12–24 DBC.IndexConstraints ............................................................................12–24 DBC.IndexStats ........................................................................................12–25 DBC.Indices[X].........................................................................................12–26 DBC.InDoubtLog .....................................................................................12–27 DBC.Journals[X].......................................................................................12–27 DBC.LogOnOff ........................................................................................12–28 Teradata RDBMS SQL/Data Dictionary Quick Reference
xxiii
Contents
DBC.LogonRules..................................................................................... 12–28 DBC.ProfileInfo[X].................................................................................. 12–29 DBC.QryLog ............................................................................................ 12–30 DBC.QryLogExplain............................................................................... 12–32 DBC.QryLogObjects ............................................................................... 12–33 DBC.QryLogSQL .................................................................................... 12–33 DBC.QryLogSteps................................................................................... 12–34 DBC.QryLogSummary........................................................................... 12–35 DBC.RCC_Configuration[X] ................................................................. 12–35 DBC.RCC_Media[X] ............................................................................... 12–35 DBC.RI_Child_Tables............................................................................. 12–36 DBC.RI_Distinct_Children .................................................................... 12–36 DBC.RI_Distinct_Parents ....................................................................... 12–37 DBC.RI_Parent_Tables ........................................................................... 12–37 DBC.RoleInfo[X]...................................................................................... 12–38 DBC.RoleMembers[X] ............................................................................ 12–38 DBC.SecurityDefaults............................................................................. 12–39 DBC.SecurityLog[X] ............................................................................... 12–39 DBC.SessionInfo[X] ................................................................................ 12–40 DBC.ShowColChecks ............................................................................. 12–41 DBC.ShowTblChecks ............................................................................. 12–41 DBC.Software_Event_Log ..................................................................... 12–42 DBC.Table_LevelConstraints ................................................................ 12–43 DBC.Tables[X] ......................................................................................... 12–44 DBC.Tables2............................................................................................. 12–45 DBC.TableSize[X].................................................................................... 12–45 DBC.TableText......................................................................................... 12–45 DBC.Triggers ........................................................................................... 12–46 DBC.UserGrantedRights........................................................................ 12–47 DBC.UserRights ...................................................................................... 12–47 DBC.UserRoleRights .............................................................................. 12–48 DBC.Users ................................................................................................ 12–49 xxiv
Teradata RDBMS SQL/Data Dictionary Quick Reference
Contents
DBC.User_Default_Journals[X] .............................................................12–50 Appendix A: How to Read Syntax Diagrams Syntax Diagram Conventions .........................................................................A–2 Appendix B: Restricted Words for V2R5.0 Reserved and Keywords for V2R5.0........................................................ B–1 Reserved Words Script .............................................................................. B–1 Running the Script...................................................................................... B–2
Teradata RDBMS SQL/Data Dictionary Quick Reference
xxv
Contents
xxvi
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 1:
Data Types and Literals
Teradata RDBMS SQL/Data Dictionary Quick Reference
1–1
Chapter 1: Data Types and Literals Byte Data Types
Byte Data Types BYTE BYTE ( n
)
attributes FF07D170
VARBYTE VARBYTE ( n
)
attributes FF07D171
1–2
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 1: Data Types and Literals Character Data Types
Character Data Types CASESPECIFIC Phrase CASESPECIFIC NOT
CS FF07D205
CHARACTER Type CHARACTER CHAR
( n )
CHARACTER SET
server_data_type
attributes FF07D190
GRAPHIC (n )
attributes FF07D234
LONG VARCHAR Type LONG VARCHAR attributes FF07D192
LONG VARGRAPHIC attributes FF07D236
UPPERCASE Phrase UPPERCASE UC FF07D206
Teradata RDBMS SQL/Data Dictionary Quick Reference
1–3
Chapter 1: Data Types and Literals Character Data Types
VARCHAR Type VARCHAR CHARACTER VARYING
( n
)
CHARACTER SET
server_data_type
CHAR VARYING
VARGRAPHIC
FF07D191
(n ) attributes FF07D235
1–4
attributes
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 1: Data Types and Literals Data Literals
Data Literals CHARACTER Data Literals 'string' _character_set 1101A009
DATE Literals DATE
quotestring FF07R017
DECIMAL Literals ± n. ±.n ±n.n KR01A143
FLOATING POINT Literals ± nE± m ± n.E± m ±.nE± m ±n.n E± m KR01A142
GRAPHIC Literals G
'< ABC >' HH01A090
Teradata RDBMS SQL/Data Dictionary Quick Reference
1–5
Chapter 1: Data Types and Literals Data Literals
Hexadecimal Literals External Client Form X
'hexadecimal digits' HH01A081
Internal DBS Form
'hexadecimal digits'
X
_character_set
C V F B V F
Character Options Byte Options
I 1 2 4
Integer Options
1101A011
INTEGER Literals ±n KR01A141
INTERVAL DAY Literals quotestring
INTERVAL
DAY
sign FF07D112
1–6
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 1: Data Types and Literals Data Literals
INTERVAL DAY TO HOUR Literals quotestring
INTERVAL
DAY TO HOUR
sign FF07D113
INTERVAL DAY TO MINUTE Literals quotestring
INTERVAL
DAY TO MINUTE
sign FF07D114
INTERVAL DAY TO SECOND Literals quotestring
INTERVAL
DAY TO SECOND
sign FF07D115
INTERVAL HOUR Literals quotestring
INTERVAL
HOUR
sign FF07D116
INTERVAL HOUR TO MINUTE Literals quotestring
INTERVAL
HOUR TO MINUTE
sign FF07D129
Teradata RDBMS SQL/Data Dictionary Quick Reference
1–7
Chapter 1: Data Types and Literals Data Literals
INTERVAL HOUR TO SECOND Literals quotestring
INTERVAL
HOUR TO SECOND
sign FF07D130
INTERVAL MINUTE Literals quotestring
INTERVAL
MINUTE
sign FF07D131
INTERVAL MINUTE TO SECOND Literals quotestring
INTERVAL
MINUTE TO SECOND
sign FF07D132
INTERVAL MONTH Literals quotestring
INTERVAL
MONTH
sign FF07D111
INTERVAL SECOND quotestring
INTERVAL
SECOND
sign FF07D133
1–8
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 1: Data Types and Literals Data Literals
INTERVAL YEAR Literals quotestring
INTERVAL sign
YEAR FF07D109
INTERVAL YEAR TO MONTH Literals quotestring
INTERVAL
YEAR TO MONTH
sign FF07D110
TIME Literals TIME
quotestring FF07D107
TIMESTAMP Literals TIMESTAMP
quotestring FF07D108
Teradata RDBMS SQL/Data Dictionary Quick Reference
1–9
Chapter 1: Data Types and Literals DateTime and Interval Data Types
DateTime and Interval Data Types DATE Data Type DATE attributes FF07D139
INTERVAL DAY Data Type INTERVAL DAY ( precision )
attributes FF07D123
INTERVAL DAY TO HOUR Data Type INTERVAL DAY
TO HOUR attributes
( precision )
FF07D124
INTERVAL DAY TO MINUTE Data Type INTERVAL DAY
TO MINUTE ( precision )
attributes FF07D125
INTERVAL DAY TO SECOND Data Type INTERVAL DAY
TO SECOND ( precision )
(fractional_seconds_precision )
attributes FF07D126
1 – 10
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 1: Data Types and Literals DateTime and Interval Data Types
INTERVAL HOUR Data Type INTERVAL HOUR ( precision )
attributes FF07D127
INTERVAL HOUR TO MINUTE Data Type INTERVAL HOUR
TO MINUTE attributes
( precision )
FF07D128
INTERVAL HOUR TO SECOND Data Type TO SECOND
INTERVAL HOUR (precision )
(fractional_seconds_precision )
attributes FF07D102
INTERVAL MINUTE Data Type INTERVAL MINUTE (precision )
attributes FF07D103
INTERVAL MINUTE TO SECOND Data Type TO SECOND
INTERVAL MINUTE (precision )
(fractional_seconds_precision )
attributes FF07D104
Teradata RDBMS SQL/Data Dictionary Quick Reference
1 – 11
Chapter 1: Data Types and Literals DateTime and Interval Data Types
INTERVAL MONTH Data Type INTERVAL MONTH
(precision)
attributes
1101A013
INTERVAL SECOND Data Type INTERVAL SECOND (precision
)
attributes
,fractional_seconds_precision FF07D105
INTERVAL YEAR Data Type INTERVAL YEAR attributes
( precision )
FF07D121
INTERVAL YEAR TO MONTH Data Type INTERVAL YEAR
TO MONTH ( precision )
attributes FF07D122
TIME Data Type TIME (fractional_seconds_precision )
attributes FF07D117
1 – 12
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 1: Data Types and Literals DateTime and Interval Data Types
TIME WITH TIME ZONE Data Type WITH TIME ZONE
TIME
attributes
(fractional_seconds_precision )
FF07D119
TIMESTAMP Data Type TIMESTAMP (fractional_seconds_precision )
attributes FF07D118
TIMESTAMP WITH TIME ZONE Data Type WITH TIME ZONE
TIMESTAMP (fractional_seconds_precision )
attributes FF07D120
Teradata RDBMS SQL/Data Dictionary Quick Reference
1 – 13
Chapter 1: Data Types and Literals Decimal/Numeric Data Types
Decimal/Numeric Data Types BYTEINT Data Type BYTEINT attributes FF07D186
DECIMAL/NUMERIC Data Type DECIMAL DEC
( n
NUMERIC
attributes
) ,m
FF07D185
FLOAT/REAL/DOUBLE PRECISION Data Type FLOAT attributes
REAL DOUBLE PRECISION
FF07D189
INTEGER Data Type INTEGER INT
attributes FF07D188
SMALLINT Data Type SMALLINT attributes FF07D187
1 – 14
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 1: Data Types and Literals Default Value Control Phrases
Default Value Control Phrases COMPRESS Phrase COMPRESS NULL const FF07A066
DEFAULT Phrase constant_value DATE quotestring TIME quotestring TIMESTAMP quotestring INTERVAL quotestring sign
DEFAULT
qualifier FF07R018
NOT NULL Phrase NOT NULL FF07D148
WITH DEFAULT Phrase WITH DEFAULT FF07D149
Teradata RDBMS SQL/Data Dictionary Quick Reference
1 – 15
Chapter 1: Data Types and Literals Output Format Phrases
Output Format Phrases AS value_expression
name AS
FF07D146
FORMAT 'format_string'
FORMAT
FF07D250
NAMED (expression)
(NAMED
name) FF07D147
TITLE TITLE
quotestring FF07D145
1 – 16
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2:
SQL Functions and Expressions
Teradata RDBMS SQL/Data Dictionary Quick Reference
2–1
Chapter 2: SQL Functions and Expressions Aggregate Functions
Aggregate Functions AVG AVERAGE
(
column_expression
AVG
)
DISTINCT
AVE FF07D210
CORR CORR
(
value_expression_1, value_expression_2
) KO01A022
COUNT COUNT
(
column_name
)
DISTINCT * FF07D211
COVAR_POP COVAR_POP
(
)
value_expression_1, value_expression_2
KO01A021
COVAR_SAMP COVAR_SAMP
(
value_expression_1, value_expression_2
) KO01A046
2–2
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Aggregate Functions
KURTOSIS KURTOSIS
(
)
value_expression DISTINCT
KO01A020
MAX MAXIMUM
(
column_name
MAX
)
DISTINCT column_expression FF07D212
MIN MINIMUM
(
column_name
MIN
)
DISTINCT column_expression FF07D213
REGR_AVGX REGR_AVGX
(
dependent_column_expression, independent_column_expression
) KO01A041
REGR_AVGY REGR_AVGY
(
dependent_column_expression, independent_column_expression
) KO01A042
REGR_COUNT REGR_COUNT
(
dependent_column_expression, independent_column_expression
) KO01A040
Teradata RDBMS SQL/Data Dictionary Quick Reference
2–3
Chapter 2: SQL Functions and Expressions Aggregate Functions
REGR_INTERCEPT REGR_INTERCEPT
(
dependent_column_expression, independent_column_expression
) KO01B024
REGR_R2 REGR_R2
(
dependent_column_expression, independent_column_expression
) KO01A039
REGR_SLOPE REGR_SLOPE
(
dependent_column_expression, independent_column_expression
) KO01B023
REGR_SXX REGR_SXX
(
dependent_column_expression, independent_column_expression
) KO01A043
REGR_SXY REGR_SXY
(
dependent_column_expression, independent_column_expression
) KO01A045
REGR_SYY REGR_SYY
(
dependent_column_expression, independent_column_expression
) KO01A044
2–4
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Aggregate Functions
SKEW SKEW
(
value_expression DISTINCT
) KO01A019
STDDEV_POP STDDEV_POP
(
)
value_expression DISTINCT
KO01A016
STDDEV_SAMP STDDEV_SAMP
(
)
value_expression DISTINCT
KO01A015
SUM SUM
(
column_expression DISTINCT
) FF07D214
VAR_POP VARIANCEP
(
value_expression DISTINCT
VAR_POP
) KO01A018
VAR_SAMP VARIANCE VAR_SAMP
(
value_expression DISTINCT
) KO01A017
Teradata RDBMS SQL/Data Dictionary Quick Reference
2–5
Chapter 2: SQL Functions and Expressions Arithmetic Operators and Functions/Trigonometric/Hyperbolic Functions
Arithmetic Operators and Functions/Trigonometric/Hyperbolic Functions Arithmetic Operators Teradata supports the following arithmetic operators: Operator
**
Function
Exponentiate This is a Teradata extension to the ANSI SQL-99 standard.
*
Multiply
/
Divide
MOD
Modulo (remainder). MOD calculates the remainder in a division operation. For example, 60 MOD 7 = 4: 60 divided by 7 equals 8, with a remainder of 4. The result takes the sign of the dividend, thus: -17 MOD 4 = -1 -17 MOD -4 = -1 17 MOD -4 = 1 17 MOD 4 = 1 This is a Teradata extension to the ANSI SQL-99 standard.
2–6
+
Add
-
Subtract
+
Unary plus (positive value)
-
Unary minus (negative value)
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Arithmetic Operators and Functions/Trigonometric/Hyperbolic Functions
ABS
ABS
(
)
arg
KK01A010
ACOS
ACOS
(
)
arg
KO01A020
ACOSH ACOSH
(
)
arg
KO01A021
ASIN
ASIN
(
arg
) KO01A022
Teradata RDBMS SQL/Data Dictionary Quick Reference
2–7
Chapter 2: SQL Functions and Expressions Arithmetic Operators and Functions/Trigonometric/Hyperbolic Functions
ASINH
ASINH
(
arg
) KO01A023
ATAN
ATAN
(
arg
) KO01A024
ATAN2
ATAN2
(
x, y
)
KO01A025
2–8
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Arithmetic Operators and Functions/Trigonometric/Hyperbolic Functions
ATANH
ATANH
(
)
arg
KO01A026
CASE_N , (
CASE_N
A
conditional_expression
A
) ,
NO CASE OR UNKNOWN , UNKNOWN UNKNOWN 1101A069
COS
COS
(
arg
) KO01A027
Teradata RDBMS SQL/Data Dictionary Quick Reference
2–9
Chapter 2: SQL Functions and Expressions Arithmetic Operators and Functions/Trigonometric/Hyperbolic Functions
COSH
COSH
(
)
arg
KK01a001
EXP EXP
(
arg
) KK01A002
LN LN
(
arg
) KK01A003
LOG LOG
(
arg
) KK01A004
2 – 10
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Arithmetic Operators and Functions/Trigonometric/Hyperbolic Functions
NULLIFZERO NULLIFZERO
(
arg
)
1101E225
RANDOM RANDOM
(
lower_bound, upper_bound
)
1101B025
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 11
Chapter 2: SQL Functions and Expressions Arithmetic Operators and Functions/Trigonometric/Hyperbolic Functions
RANGE_N RANGE_N A
(
test_expression
start_expression
*
A
BETWEEN
AND
end_expression
AND
* end_expression
B EACH
range_size
* | range_list | B
) ,
NO RANGE OR UNKNOWN , UNKNOWN UNKNOWN range_list C
start_expression AND
end_expression
AND
end_expression
EACH
range_size
*
D
C ,
start_expression AND
D
,
start_expression
AND
end_expression
EACH
range_size
EACH
range_size
end_expression *
1101A068
2 – 12
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Arithmetic Operators and Functions/Trigonometric/Hyperbolic Functions
SIN
SIN
(
arg
) KK01A005
SINH
SINH
(
arg
) KK01A006
SQRT
SQRT
(
arg
) KK01A007
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 13
Chapter 2: SQL Functions and Expressions Arithmetic Operators and Functions/Trigonometric/Hyperbolic Functions
TAN
TAN
(
)
arg
KK01A008
TANH
TANH
(
)
arg
KK01A009
WIDTH_BUCKET WIDTH BUCKET
(
value_expression, lower_bound, upper_bound, partition_count
)
1101A004
ZEROIFNULL ZEROIFNULL
(
arg
)
1101E226
2 – 14
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Attribute Functions
Attribute Functions BYTES BYTE
byte_expression S FF07D174
CHARACTERS CHARACTERS
( string_expression
)
CHARS CHAR
FF07D165
CHARACTER_LENGTH CHARACTER_LENGTH CHAR_LENGTH
(string_expression) FF07D088
FORMAT FORMAT
( column_name ) FF07D166
MCHARACTERS MCHARACTERS
(string_expression ) FF07D217
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 15
Chapter 2: SQL Functions and Expressions Attribute Functions
OCTET_LENGTH OCTET_LENGTH
(
string_expression
) character_set_name FF07D218
TYPE TYPE
(
expression
) FF07D169
2 – 16
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Built-In Functions
Built-In Functions ACCOUNT ACCOUNT FF07R001
CURRENT_DATE CURRENT_DATE FF07D135
CURRENT_TIME CURRENT_TIME (fractional_precision ) FF07D136
CURRENT_TIMESTAMP CURRENT_TIMESTAMP (fractional_precision ) FF07D137
DATABASE DATABASE FF07R002
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 17
Chapter 2: SQL Functions and Expressions Built-In Functions
DATE DATE FF07D134
PROFILE PROFILE KZ01A006
ROLE ROLE KZ01A007
SESSION SESSION FF07R003
TIME TIME FF07D271
USER USER FF07D272
2 – 18
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions CASE Expressions
CASE Expressions Valued CASE Expression CASE
A
WHEN
value_expression_1
value_expression_n
A
THEN
scalar_expression_n
B
END
B ELSE scalar_expression_m
1101A012
Searched CASE Expression CASE
WHEN
search_condition_n
THEN
scalar_expression_n
A
END
A ELSE
scalar_expression_m FF07D224
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 19
Chapter 2: SQL Functions and Expressions CASE Expressions
COALESCE Expression , COALESCE
(
2
scalar_expression_n
) 1101E227
NULLIF Expression NULLIF
(
scalar_expression1, scalar_expression2
)
HH01B094
2 – 20
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Comparison Operators
Comparison Operators ANSI Operator
Teradata Extensions
=
EQ
Tests for equality.
^=
Tests for inequality.
Function
NE NOT=
=
GE
Tests for greater than or equal.
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 21
Chapter 2: SQL Functions and Expressions Comparison Operators
Comparison Operators Syntax scalar_expression
comparison_operator
scalar_expression FF07D160
expression_1
operator
expression_2
expression_1
operator
quantifier
expression_1
operator
expression_1
, constant
)
( subquery ) quantifier
, (
(
)
( subquery )
operator quantifier
1101D219
2 – 22
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Data Type Conversions
Data Type Conversions CAST CAST
( expression
AS
ansi_sql_data_type
)
data_type_list KK01A011
Teradata Conversion Syntax expression
( data_type_list ) HH01A019
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 23
Chapter 2: SQL Functions and Expressions DateTime and Interval Functions and Expressions
DateTime and Interval Functions and Expressions Arithmetic Operators and Result Types The following arithmetic operations are permitted for DateTime and Interval data types: First Value Type
2 – 24
Operator
Second Value Type
Result Type
DateTime
-
DateTime
Interval
DateTime
+
Interval
DateTime
DateTime
-
Interval
DateTime
Interval
+
DateTime
DateTime
Interval
+
Interval
Interval
Interval
-
Interval
Interval
Interval
*
Number
Interval
Interval
/
Number
Interval
Number
*
Interval
Interval
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions DateTime and Interval Functions and Expressions
ANSI DateTime Expressions date_time_expression Syntax date_time_term interval_expression
+
date_time_term
date_time_expression
±
interval_term FF07D266
date_time_term Syntax date_time_primary AT
LOCAL TIME ZONE
interval_expression FF07D265
ANSI Interval Expressions interval_expression Syntax interval_term interval_expression (
±
date_time_expression
interval_term date_time_term
)
start TO end 1101A010
interval_term Syntax ±
interval_primary
interval_term
*
numeric_factor
/ numeric_term
*
interval_factor FF07D268
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 25
Chapter 2: SQL Functions and Expressions DateTime and Interval Functions and Expressions
numeric_term Syntax numeric_factor numeric_term
*
numeric_factor
/
FF07D270
numeric_factor Syntax ±
numeric_primary FF07D269
ADD_MONTHS Date Syntax ADD_MONTHS
( date_expression, integer_expression ) FF07D202
Timestamp Syntax ADD_MONTHS
(timestamp_expression, integer_expression ) FF07D208
2 – 26
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions DateTime and Interval Functions and Expressions
EXTRACT EXTRACT
(
YEAR
FROM
value )
MONTH DAY HOUR MINUTE SECOND TIMEZONE_HOUR TIMEZONE_MINUTE
FF07D144
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 27
Chapter 2: SQL Functions and Expressions Hash-Related Functions
Hash-Related Functions HASHAMP
HASHAMP
(
) expression HH01A027
HASHBAKAMP
HASHBAKAMP
(
) expression HH01A028
HASHBUCKET
HASHBUCKET
(
) expression HH01A026
2 – 28
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Hash-Related Functions
HASHROW HASHROW
(
, expression
) 1101B026
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 29
Chapter 2: SQL Functions and Expressions Logical Predicates
Logical Predicates ANY/ALL/SOME Subquery Syntax Syntax 1
, expression
comparison_operator
ALL ANY SOME
constant
(
)
1101A090
Syntax 2
(
, expression
)
comparison_operator
ALL ANY SOME
( subquery )
1101B041
BETWEEN/NOT BETWEEN expr1
BETWEEN
expr2
AND
expr3
NOT HH01A038
EXISTS/NOT EXISTS EXISTS
subquery
NOT HH01A047
2 – 30
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Logical Predicates
IN/NOT IN Syntax 1 expression_1
IN
expression_2 ,
NOT (
constant
)
datetime_literal HH01B001
Syntax 2 expression
IN
(
subquery
)
NOT , (
IN
)
expression
(
subquery
NOT
) HH01B002
IS NULL/IS NOT NULL expression
IS
NULL NOT HH01A042
Logical Operator expression_1
OR
expression_2
OR
expression_3 FF07D220
expression_1
AND NOT
expression_2 FF07D221
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 31
Chapter 2: SQL Functions and Expressions Logical Predicates
LIKE expression
LIKE
pattern_expression
NOT
expression
ESCAPE
LIKE
escape_character
( subquery )
NOT
ALL
ESCAPE
escape_character
ANY SOME , (
expression
LIKE
)
( subquery )
NOT
ESCAPE
ALL
escape_character
ANY SOME
, expression
(
, )
LIKE
(
NOT
pattern_expression
) ESCAPE
ALL
escape_character
ANY SOME FF07D196
OVERLAPS (
datetime_expression, datetime_expression
)
OVERLAPS
( datetime_expression, datetime_expression
datetime_expression, interval_expression
datetime_expression, interval_expression
row_subquery
row_subquery
)
FF07D164
2 – 32
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Ordered Analytical Functions
Ordered Analytical Functions AVG AVG
(
value_expression
)
OVER
A
( , PARTITION BY
column_reference
B
A , ORDER BY
value_expression ASC DESC
B
) ROWS
UNBOUNDED PRECEDING value
PRECEDING
CURRENT ROW ROWS BETWEEN
UNBOUNDED PRECEDING AND
UNBOUNDED FOLLOWING value
PRECEDING
CURRENT ROW value value
PRECEDING AND
FOLLOWING
UNBOUNDED FOLLOWING value
PRECEDING
CURRENT ROW value CURRENT ROW AND
FOLLOWING
UNBOUNDED FOLLOWING CURRENT ROW value
value
FOLLOWING AND
FOLLOWING
UNBOUNDED FOLLOWING value
FOLLOWING 1101B101
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 33
Chapter 2: SQL Functions and Expressions Ordered Analytical Functions
COUNT COUNT
(
value_expression
)
OVER
A
( ,
* PARTITION BY
column_reference
B
A , ORDER BY
value_expression ASC DESC
B
) ROWS
UNBOUNDED PRECEDING value
PRECEDING
CURRENT ROW ROWS BETWEEN
UNBOUNDED PRECEDING AND
UNBOUNDED FOLLOWING value
PRECEDING
CURRENT ROW value value
PRECEDING AND
FOLLOWING
UNBOUNDED FOLLOWING value
PRECEDING
CURRENT ROW value CURRENT ROW AND
FOLLOWING
UNBOUNDED FOLLOWING CURRENT ROW value
value
FOLLOWING AND
FOLLOWING
UNBOUNDED FOLLOWING value
FOLLOWING 1101B102
2 – 34
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Ordered Analytical Functions
CSUM CSUM
(value_expression, sort_expression_list) FF07D080
MAVG MAVG
(value_expression, width, sort_expression_list) FF07D082
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 35
Chapter 2: SQL Functions and Expressions Ordered Analytical Functions
MAX MAX
(
value_expression
)
OVER
A
( , PARTITION BY
column_reference
B
A , ORDER BY
value_expression ASC DESC
B
) ROWS
UNBOUNDED PRECEDING value
PRECEDING
CURRENT ROW ROWS BETWEEN
UNBOUNDED PRECEDING AND
UNBOUNDED FOLLOWING value
PRECEDING
CURRENT ROW value value
PRECEDING AND
FOLLOWING
UNBOUNDED FOLLOWING value
PRECEDING
CURRENT ROW value CURRENT ROW AND
FOLLOWING
UNBOUNDED FOLLOWING CURRENT ROW value
value
FOLLOWING AND
FOLLOWING
UNBOUNDED FOLLOWING value
FOLLOWING 1101B105
2 – 36
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Ordered Analytical Functions
MDIFF MDIFF
(value_expression, width, sort_expression_list) FF07D083
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 37
Chapter 2: SQL Functions and Expressions Ordered Analytical Functions
MIN MIN
(
value_expression
)
OVER
A
( , PARTITION BY
column_reference
B
A , value_expression
ORDER BY
ASC DESC B
) ROWS
UNBOUNDED PRECEDING value
PRECEDING
CURRENT ROW ROWS BETWEEN
UNBOUNDED PRECEDING AND
UNBOUNDED FOLLOWING value
PRECEDING
CURRENT ROW value value
PRECEDING AND
FOLLOWING
UNBOUNDED FOLLOWING value
PRECEDING
CURRENT ROW value CURRENT ROW AND
FOLLOWING
UNBOUNDED FOLLOWING CURRENT ROW value
value
FOLLOWING AND
FOLLOWING
UNBOUNDED FOLLOWING value
FOLLOWING 1101B106
2 – 38
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Ordered Analytical Functions
MLINREG MLINREG
(value_expression, width, sort_expression) FF07D081
MSUM MSUM
(value_expression, width, sort_expression_list) FF07D084
PERCENT_RANK PERCENT_RANK()
OVER
A
( , PARTITION BY
column_reference
, A
ORDER BY
value_expression
) ASC DESC 1101B107
QUANTILE QUANTILE
(quantile_constant, sort_expression_list) FF07D085
RANK Teradata - Specific Function RANK
(sort_expression_list) FF07D086
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 39
Chapter 2: SQL Functions and Expressions Ordered Analytical Functions
SQL-99 Window Function RANK()
OVER
A
( , PARTITION BY
column_reference ,
A
ORDER BY
value_expression
) ASC DESC 1101B100
ROW_NUMBER ROW_NUMBER()
OVER
A
( , PARTITION BY
column_reference
, A
ORDER BY
value_expression
) ASC DESC
2 – 40
1101B108
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Ordered Analytical Functions
SUM SUM
(
value_expression
)
OVER
A
( , PARTITION BY
column_reference
B
A , value_expression
ORDER BY
ASC DESC B
) ROWS
UNBOUNDED PRECEDING value
PRECEDING
CURRENT ROW ROWS BETWEEN
UNBOUNDED PRECEDING AND
UNBOUNDED FOLLOWING value
PRECEDING
CURRENT ROW value value
PRECEDING AND
FOLLOWING
UNBOUNDED FOLLOWING value
PRECEDING
CURRENT ROW value CURRENT ROW AND
FOLLOWING
UNBOUNDED FOLLOWING CURRENT ROW value
value
FOLLOWING AND
FOLLOWING
UNBOUNDED FOLLOWING value
FOLLOWING 1101B104
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 41
Chapter 2: SQL Functions and Expressions Set Operators
Set Operators Syntax for query_term SELECT
statement
(query_expression ) FF07D178
Syntax for query_factor query_term query_factor
INTERSECT
query_term ALL HH01A061
Syntax for query_expression query_factor query_expression
query_factor
UNION MINUS EXCEPT
,
ALL (query_expression )
ORDER BY
expression ASC DESC FF07D179
2 – 42
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions Set Operators
INTERSECT Operator Syntax query_expression_1
INTERSECT
query_expression_2 ALL FF07D176
Semantics query factor
INTERSECT
query term ALL FF06A021
MINUS/EXCEPT Operator Syntax query_expression_1
MINUS EXCEPT
query_expression_2 ALL FF07D177
Semantics query_factor query_expression
query_factor
UNION MINUS EXCEPT
,
ALL (query_expression )
ORDER BY
expression ASC DESC FF07D179
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 43
Chapter 2: SQL Functions and Expressions Set Operators
UNION Operator Syntax query_expression_1
UNION
query_expression_2 ALL FF07D175
Semantics query expr
UNION
query factor ALL FF06A020
2 – 44
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions String Functions
String Functions CHAR2HEXINT
CHAR2HEXINT
( character_string_expression ) 1101E173
Concatenation Operator string_expression_1
string_expression_2 string_expression_n FF07D195
INDEX INDEX
( string_expression_1 ,string_expression_2 ) FF07D253
LOWER LOWER
(character_string_expression) FF07D091
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 45
Chapter 2: SQL Functions and Expressions String Functions
POSITION POSITION
IN
(string_expression_1
string_expression_2) FF07D090
SOUNDEX SOUNDEX
(
)
string_expression
KO01A060
SUBSTRING/SUBSTR ANSI Syntax SUBSTRING
(string_expression
FROM
n1
) FOR n2 FF07D256
Teradata Syntax SUBSTR
(string_expression,n1
) ,n2
FF07D257
TRANSLATE TRANSLATE
(
character_string_expression
USING
source_repertoire_name
_TO _target_repertoire_name
A _encoding
A
) _suffix
WITH ERROR
1101E198
2 – 46
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 2: SQL Functions and Expressions String Functions
TRANSLATE_CHK TRANSLATE_CHK
(
character_string_expression
USING
_encoding
A
)
_TO _target_repertoire_name
A
source_repertoire_name
_suffix 1101E199
TRIM TRIM
(
string_expression BOTH TRAILING
FROM
)
character_set
trim_character
LEADING
1101E200
UPPER UPPER
( character_string_expression ) FF07D258
VARGRAPHIC VARGRAPHIC
( character_string_expression ) 1101E197
Teradata RDBMS SQL/Data Dictionary Quick Reference
2 – 47
Chapter 2: SQL Functions and Expressions String Functions
2 – 48
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3:
SQL Data Definition Language Statement Syntax
Teradata RDBMS SQL/Data Dictionary Quick Reference
3–1
Chapter 3: SQL Data Definition Language Statement Syntax ALTER PROCEDURE
ALTER PROCEDURE procedure_name
ALTER PROCEDURE
A
COMPILE
database_name. A
, WITH NO NO
3–2
SPL
;
WARNING 1101Q001
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax ALTER TABLE
ALTER TABLE Basic Table Parameters Modification Syntax ,
table_name
ALTER TABLE
database_name.
A
,
FALLBACK PROTECTION NO WITH JOURNAL TABLE =
table_name
database_name. JOURNAL NO
BEFORE
DUAL ON COMMIT
DELETE
ROWS
PRESERVE LOG NO AFTER JOURNAL NO Alter Table Options
DUAL LOCAL NOT LOCAL CHECKSUM = integrity_checking_level IMMEDIATE DEFAULT FREESPACE FREESPACE = integer PERCENT DATABLOCKSIZE = integer
IMMEDIATE BYTES KBYTES KILOBYTES
MINIMUM
DATABLOCKSIZE
MAXIMUM DEFAULT
Teradata RDBMS SQL/Data Dictionary Quick Reference
3–3
Chapter 3: SQL Data Definition Language Statement Syntax ALTER TABLE
, A ADD column_name
data type declaration data type attributes data type attributes
COMPRESS
constant ,
Table Column Definition
255
constant NULL
(
Column Storage Attributes
Column Changes
)
UNIQUE CONSTRAINT name
PRIMARY KEY
Column Constraint Attributes
CHECK
boolean_condition
(
)
table_name
REFERENCES WITH
CHECK OPTION
ADD
column_name
, ( column_name )
NO
NULL
column_name
DROP RENAME
old_column_name
ADD
new_column_name TO , AS FOREIGN KEY ( column_name ) REFERENCES
CONSTRAINT name
DROP
table_name WITH
CHECK OPTION NO
,
Reference Definition
( column_name )
DROP INCONSISTENT REFERENCES ADD
CHECK
boolean_condition
(
)
column_name Constraint Changes
CONSTRAINT name DROP
CHECK
column_name
MODIFY
CONSTRAINT name column_name
CHECK
(
boolean_condition
)
CONSTRAINT name DROP
CONSTRAINT name
ADD
, UNIQUE
CONSTRAINT name
(
Unique Definition
column_name )
PRIMARY KEY 1101E034
3–4
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax ALTER TABLE
Primary Index Modification Syntax ALTER TABLE
table_name
MODIFY
A
PRIMARY INDEX index_name
UNIQUE
database_name. NOT
, (
NOT NAMED
column_name
)
A NOT PARTITIONED PARTITION BY
;
partitioning_expression WITH
DELETE INSERT
save_table INTO
DROP RANGE
WHERE
conditional_expression
BETWEEN
B
start_expression AND
end_expression
EACH
,
range_size
NO RANGE OR UNKNOWN ,
UNKNOWN
B , ADD RANGE
BETWEEN
C
start_expression AND
end_expression
EACH
range_size
C ,
WITH
NO RANGE OR UNKNOWN , ,
DELETE save_table
INSERT
UNKNOWN
INTO
UNKNOWN ,
ADD RANGE
BETWEEN
start_expression AND
end_expression
EACH
range_size
,
NO RANGE OR UNKNOWN , ,
UNKNOWN
Teradata RDBMS SQL/Data Dictionary Quick Reference
UNKNOWN 1101B112
3–5
Chapter 3: SQL Data Definition Language Statement Syntax ALTER TABLE
Partitioned Primary Index Revalidation Syntax ALTER TABLE
table_name
REVALIDATE PRIMARY INDEX
A
database_name. A WITH
;
DELETE INSERT
save_table INTO HH01A001
3–6
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax ALTER TRIGGER
ALTER TRIGGER
ALTER TRIGGER database_name.
trigger_name
ENABLED
table_name
DISABLED
; FF07D039
Teradata RDBMS SQL/Data Dictionary Quick Reference
3–7
Chapter 3: SQL Data Definition Language Statement Syntax BEGIN LOGGING
BEGIN LOGGING BEGIN LOGGING
ON DENIALS
A
WITH TEXT
FIRST LAST FIRST AND LAST EACH
A
ALL , operation GRANT
, BY
database_name
ON
DATABASE database_name USER user_name TABLE VIEW
object_name database_name .
MACRO PROCEDURE
3–8
Teradata RDBMS SQL/Data Dictionary Quick Reference
1101S044
Chapter 3: SQL Data Definition Language Statement Syntax COMMENT
COMMENT object_name
COMMENT ON
'string'
DATABASE USER
AS
TABLE
IS
;
VIEW MACRO COLUMN TRIGGER PROCEDURE
FF07D041
PROFILE ROLE
Teradata RDBMS SQL/Data Dictionary Quick Reference
3–9
Chapter 3: SQL Data Definition Language Statement Syntax CREATE DATABASE
CREATE DATABASE name
CREATE DATABASE
A
AS FROM database_name
CD
, A
PERMANENT
= n ;
BYTES
PERM SPOOL = n BYTES TEMPORARY = n bytes ACCOUNT =
'account_ID'
FALLBACK NO
PROTECTION JOURNAL NO
BEFORE
DUAL AFTER JOURNAL NO DUAL LOCAL NOT LOCAL table_name
DEFAULT JOURNAL TABLE = database_name.
3 – 10
Teradata RDBMS SQL/Data Dictionary Quick Reference
1101E030
Chapter 3: SQL Data Definition Language Statement Syntax CREATE HASH INDEX
CREATE HASH INDEX CREATE HASH INDEX
A
hash_index_name ,
FALLBACK
A
( column_name_1
PROTECTION
NO
, ) ON
table_name
B , BY
column_name_2
B ORDER BY
;
VALUES , VALUES
(
column_name_3 ,
)
HASH
(
column_name_3
)
, (
column_name_3
)
Teradata RDBMS SQL/Data Dictionary Quick Reference
1101F379
3 – 11
Chapter 3: SQL Data Definition Language Statement Syntax CREATE INDEX
CREATE INDEX , CREATE
INDEX UNIQUE
A index_name
ALL
, A
( column_name_1 )
B ( column_name_2 )
ORDER BY VALUES HASH B
ON
table_name ;
TEMPORARY join_index_name
FF07D004
3 – 12
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax CREATE JOIN INDEX
CREATE JOIN INDEX Multitable Syntax CREATE JOIN INDEX
join_index_name
AS SELECT ,
A
FALLBACK NO
PROTECTION
, column_1_name
A
B
ROWID EXTRACT
(
YEAR
FROM
date_expression
,
, 16 column_2_name
)
AS
correlation_name
MONTH , 16 column_1_name
(
)
(
)
ROWID
ROWID , column_name
ROWID ( numeric_expression ) AS correlation_name COUNT ( column_expression ) EXTRACT ( YEAR FROM date_expression ) AS correlation_name SUM
MONTH B
FROM
table_name
C correlation_name
WHERE
search_condition
AS joined_table D
C , GROUP BY
column_name column_position
D
, ORDER BY
column_name column_position
indexes ; 1101E294
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 13
Chapter 3: SQL Data Definition Language Statement Syntax CREATE JOIN INDEX joined_table (joined_table) JOIN
joined_table
joined_table
ON
search_condition
INNER LEFT RIGHT
OUTER
table_name correlation_name AS 1101E050
indexes , , INDEX PRIMARY
( index_name
ALL
16
column_name_1
) ORDER BY
HASH VALUES
(column_name_2)
(column_name_2) FF07D051
3 – 14
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax CREATE JOIN INDEX
Single-Table Syntax join_index_name
CREATE JOIN INDEX
AS SELECT ,
A
FALLBACK NO
PROTECTION
, column_1_name
A
B
ROWID (
EXTRACT
YEAR
FROM
date_expression
AS
)
correlation_name
MONTH ,
16 column_1_name
(
,
)
,
16 column_2_name
(
)
ROWID
ROWID , column_name SUM
ROWID ( numeric_expression
COUNT ( EXTRACT (
)
AS
correlation_name
column_expression ) YEAR FROM date_expression
)
AS
correlation_name
MONTH B
FROM
table_name
C correlation_name
GROUP BY
AS
column_name column_position
indexes
C ORDER BY
column_name
;
column_position 1101E295
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 15
Chapter 3: SQL Data Definition Language Statement Syntax CREATE JOIN INDEX
indexes , , (
INDEX PRIMARY
index_name
ALL
16
column_name_1
) ORDER BY
HASH VALUES
(column_name_2)
(column_name_2) FF07D051
3 – 16
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax CREATE/REPLACE MACRO
CREATE/REPLACE MACRO CREATE MACRO
A
macro_name ,
CM
( parameter_name type declaration
REPLACE MACRO
) type attribute
A
AS (
statement ; USING modifier
)
LOCKING modifier
; 1101E172
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 17
Chapter 3: SQL Data Definition Language Statement Syntax CREATE/REPLACE PROCEDURE
CREATE/REPLACE PROCEDURE CREATE
PROCEDURE
REPLACE A
A
procedure_name database_name.
(
, 256 parameter_name
IN
)
;
statement
data_type
OUT INOUT 1101Q002
statement SQL_statement compound statement assignment statement condition statement iteration statement label_name :
label_name
ITERATE
label_name
LEAVE
label_name YS6CP01B
compound statement BEGIN label_name :
B local_declaration
B
cursor_declaration END
condition_handler
statement_list
label_name YS6CP01C
3 – 18
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax CREATE/REPLACE PROCEDURE
local_declaration
DECLARE
, variable_name
data_type
; DEFAULT
literal NULL
cursor_declaration DECLARE
cursor_name
C
CURSOR FOR SCROLL NO SCROLL
C
;
cursor_specification FOR
READ ONLY UPDATE
YS6CP02a
condition-handler
DECLARE
HANDLER
CONTINUE
FOR
D
EXIT , D
SQLSTATE
sqlstate_code
handler_action _statement
;
VALUE , SQLEXCEPTION SQLWARNING NOT FOUND
Teradata RDBMS SQL/Data Dictionary Quick Reference
YS6CP02b
3 – 19
Chapter 3: SQL Data Definition Language Statement Syntax CREATE/REPLACE PROCEDURE
assignment statement assignment_target =
SET
assignment_source
; YS6CP02C
condition statement
CASE
WHEN
operand_2
WHEN
operand_1
conditional_expression
THEN THEN
J
;
statement END CASE
ELSE IF
J
statement
statement
conditional_expression
THEN
G
statement
G
H ELSEIF
conditional_expression
THEN
statement
END IF
H ELSE
statement YS6CP03A
iteration statement
WHILE
conditional-expression
LOOP FOR
DO
statement for-loop-variable
statement
REPEAT
E
cursor-specification statement
;
END LOOP
AS cursor-name
E
END WHILE
UNTIL
DO
CURSOR FOR statement
conditional_expression
END FOR END REPEAT YS6CP03B
3 – 20
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax CREATE/REPLACE PROCEDURE
cursor-specification , SELECT
column_name
FROM
, table_name
F
correlation_name AS expression
correlation_name AS ,
F WHERE clause
other SELECT clauses YS6CP03C
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 21
Chapter 3: SQL Data Definition Language Statement Syntax CREATE PROFILE
CREATE PROFILE CREATE PROFILE
A
profile_name
A , ; AS
ACCOUNT = (
'account_id' , 'account_id'
)
NULL DEFAULT DATABASE =
database_name NULL
SPOOL =
n BYTES NULL
TEMPORARY =
n BYTES NULL ,
PASSWORD
= ATTRIBUTES
(
EXPIRE =
n NULL
MINCHAR =
n NULL
MAXCHAR =
n NULL
DIGITS =
c NULL
SPECCHAR =
c NULL
MAXLOGONATTEMPTS = LOCKEDUSEREXPIRE = REUSE =
)
n NULL n NULL
n NULL NULL
3 – 22
Teradata RDBMS SQL/Data Dictionary Quick Reference
KZ01a001
Chapter 3: SQL Data Definition Language Statement Syntax CREATE ROLE
CREATE ROLE
CREATE ROLE
role_name ; KZ01A003
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 23
Chapter 3: SQL Data Definition Language Statement Syntax CREATE TABLE
CREATE TABLE Create Table Syntax , TABLE table_name
CREATE SET MULTISET CT
GLOBAL TEMPORARY VOLATILE
,
A FALLBACK NO WITH JOURNAL TABLE =
PROTECTION table_name database_name.
LOG NO JOURNAL NO
BEFORE
DUAL AFTER JOURNAL NO Create Table Options
DUAL LOCAL NOT LOCAL CHECKSUM = integrity_checking_level FREESPACE = integer PERCENT DATABLOCKSIZE= integer
BYTE
S
KBYTE
S
KILOBYTE MINIMUM
DATABLOCKSIZE
MAXIMUM
3 – 24
Teradata RDBMS SQL/Data Dictionary Quick Reference
S
Chapter 3: SQL Data Definition Language Statement Syntax CREATE TABLE ‘ A
(
column_name
,
data type declaration
) B data type attributes
COMPRESS
constant ,
255
constant
(
Column Storage Attributes
)
NULL Column Definition UNIQUE CONSTRAINT name
PRIMARY KEY CHECK
(
boolean condition
table_name WITH
CHECK OPTION
( column_name
NO GENERATED
ALWAYS BY DEFAULT
Column Constraint Attributes
)
REFERENCES
)
AS IDENTITY (
(
START WITH INCREMENT BY MINVALUE NO MAXVALUE NO CYCLE NO
Table Level Definition
, UNIQUE
Unique Definition
CONSTRAINT
Check Definition
column_name
) REFERENCES
column_name
table_name WITH
CONSTRAINT name
,
CHECK OPTION
( column_name )
NO CHECK
CONSTRAINT
)
PRIMARY KEY ,
name
FOREIGN KEY ( References Definition
(
(
boolean_condition
) 1101R019
name
B
C
Index Definition
,
, INDEX
( index_name
UNIQUE
column_name
)
ALL ,
PRIMARY INDEX
(
primary_index_column
)
index_name
UNIQUE
PARTITION BY
, INDEX
( index_name
column_name
)
ORDER BY
(
partitioning_expression column_name
)
VALUES
ALL
HASH C ON COMMIT
DELETE
ROWS
PRESERVE
Teradata RDBMS SQL/Data Dictionary Quick Reference
; 1101S021
3 – 25
Chapter 3: SQL Data Definition Language Statement Syntax CREATE TABLE Data Type Declarations INTEGER SMALLINT BYTEINT DATE TIME WITH TIMEZONE TIMESTAMP WITH TIMEZONE INTERVAL YEAR TO MONTH INTERVAL MONTH INTERVAL DAY TO HOUR TO MINUTE TO SECOND INTERVAL HOUR TO MINUTE TO SECOND INTERVAL MINUTE TO SECOND INTERVAL SECOND REAL DOUBLE PRECISION FLOAT ( integer ) DECIMAL NUMERIC
( integer
) , integer
CHAR BYTES
( integer )
GRAPHIC VARCHAR
( integer )
CHAR VARYING VARBYTE VARGRAPHIC LONG VARCHAR LONG VARGRAPHIC FF07D203
3 – 26
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax CREATE TABLE Data Type Attributes NOT NULL UPPERCASE UC CASESPECIFIC NOT
CS
FORMAT
quotestring
TITLE NAMED
name
DEFAULT
number USER DATE TIME NULL WITH DEFAULT
CHARACTER SET
character_data_type FF07D204
Copy Table Syntax , TABLE table_name
CREATE SET MULTISET CT
GLOBAL TEMPORARY VOLATILE
A ,
FALLBACK NO
PROTECTION
WITH JOURNAL TABLE =
table_name database_name.
LOG NO JOURNAL NO
BEFORE
DUAL AFTER JOURNAL NO Create Table Options
DUAL LOCAL NOT LOCAL CHECKSUM = integrity_checking_level FREESPACE = integer PERCENT DATABLOCKSIZE= integer BYTE
S
KBYTE
S
KILOBYTE MINIMUM
S
DATABLOCKSIZE
MAXIMUM
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 27
Chapter 3: SQL Data Definition Language Statement Syntax CREATE TABLE
Data Type Attributes NOT NULL UPPERCASE UC CASESPECIFIC NOT FORMAT
CS quotestring
TITLE NAMED DEFAULT
name number USER DATE TIME NULL WITH DEFAULT
CHARACTER SET
character_data_type FF07D204
3 – 28
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax CREATE TRIGGER REPLACE TRIGGER
CREATE TRIGGER REPLACE TRIGGER CREATE
trigger_name
TRIGGER
REPLACE
A
database_name.
INSERT
ENABLED
BEFORE
DISABLED
AFTER INSTEAD OF
ON
A
table_name ORDER integer
database_name.
DELETE
B
UPDATE , OF
column_list
(
) C
B REFERENCING
OLD_TABLE
identifier AS
NEW_TABLE
identifier AS
OLD
identifier AS
NEW
identifier AS D
C FOR EACH
ROW
WHEN
(search_condition)
STATEMENT
(
D
SQL _procedure_statement
;
) ;
BEGIN ATOMIC (
SQL _procedure_statement
;
)
END FF07D036
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 29
Chapter 3: SQL Data Definition Language Statement Syntax CREATE USER
CREATE USER CREATE USER
name
=n
PERMANENT
AS FROM database_name
A
PERM
,
BYTES
, A
PASSWORD =
password ; STARTUP = 'string;'
,
TEMPORARY = n
bytes SPOOL = n BYTES DEFAULT DATABASE = database_name COLLATION = collation_sequence ACCOUNT =
'account_ID' ( 'account_ID'
,
,'account_ID'
)
FALLBACK NO
PROTECTION JOURNAL BEFORE
NO DUAL
AFTER JOURNAL NO DUAL LOCAL NOT LOCAL
table_name
DEFAULT JOURNAL TABLE =
database_name.
TIME ZONE =
LOCAL
quotestring sign NULL DATEFORM =
INTEGERDATE ANSIDATE NULL
DEFAULT CHARACTER SET DEFAULT ROLE =
PROFILE =
character_data_type
role_name NONE NULL profile_name NULL
3 – 30
Teradata RDBMS SQL/Data Dictionary Quick Reference
1101A007
Chapter 3: SQL Data Definition Language Statement Syntax CREATE/REPLACE VIEW
CREATE/REPLACE VIEW CREATE VIEW
view_name
A
AS ,
CV
( column_name
REPLACE VIEW
)
A
B database_name
LOCKING DATABASE
LOCK
table_name
ACCESS FOR
EXCLUSIVE
IN
EXCL
TABLE
MODE
NOWAIT
SHARE view_name
READ
VIEW
WRITE
ROW B
SELECT SEL
*
DISTINCT ALL
C
,
expression alias_name AS table_name.* ,
C FROM
table_name
D Single Tables
alias_name AS joined_table
JOIN joined_table ON INNER LEFT RIGHT FULL
Joined Tables
OUTER
CROSS JOIN ( subquery )
search_condition
single_table
derived_table_name
Derived Tables
,
AS (
column_name
) E
D ,
WHERE search_condition GROUP BY
column_name column_position expression
E HAVING
condition
WITH CHECK OPTION
; 1101S077
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 31
Chapter 3: SQL Data Definition Language Statement Syntax DATABASE
DATABASE DATABASE
database_name ; FF07A016
3 – 32
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax DELETE DATABASE DELETE USER
DELETE DATABASE DELETE USER DELETE DEL
DATABASE USER
name ALL
; FF07D026
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 33
Chapter 3: SQL Data Definition Language Statement Syntax DROP DATABASE
DROP DATABASE
DROP DATABASE
database_name ; 1101A070
3 – 34
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax DROP HASH INDEX
DROP HASH INDEX
DROP HASH INDEX
hash_index_name ; FF07D380
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 35
Chapter 3: SQL Data Definition Language Statement Syntax DROP INDEX
DROP INDEX DROP index_name Syntax DROP INDEX
index_name
ON
table_name ;
TEMPORARY join_index_name
FF07D045
DROP index_definition Syntax , ( column_name )
DROP INDEX ALL
A
index_name B
A ( column_name_2 )
ORDER BY VALUES HASH B
ON
table_name ;
TEMPORARY join_index_name
FF07D003
3 – 36
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax DROP JOIN INDEX
DROP JOIN INDEX
join_index_name
DROP JOIN INDEX database_name.
; FF07D018
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 37
Chapter 3: SQL Data Definition Language Statement Syntax DROP MACRO DROP PROCEDURE DROP TABLE DROP TRIGGER DROP VIEW
DROP MACRO DROP PROCEDURE DROP TABLE DROP TRIGGER DROP VIEW DROP
MACRO
macro_name TABLE
;
table_name
TEMPORARY
ALL
TRIGGER
OVERRIDE
trigger_name database_name. VIEW
view_name
PROCEDURE
procedure_name database_name.
3 – 38
FF07D093
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax DROP PROFILE
DROP PROFILE
DROP PROFILE
profile_name ; KZ01A004
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 39
Chapter 3: SQL Data Definition Language Statement Syntax DROP ROLE
DROP ROLE
DROP ROLE
role_name ; KZ01A005
3 – 40
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax DROP USER
DROP USER
DROP USER
user_name ; 1101A071
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 41
Chapter 3: SQL Data Definition Language Statement Syntax END LOGGING
END LOGGING ON
END LOGGING DENIALS A
ALL , operation
A
WITH TEXT B , BY
database_name
GRANT B , ON
;
DATABASE database_name USER user_name object_name
TABLE VIEW
database_name.
MACRO PROCEDURE 1101E371
3 – 42
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax MODIFY DATABASE
MODIFY DATABASE , MODIFY DATABASE
dbname
AS
= number
PERMANENT
;
BYTES
PERM TEMPORARY =
number bytes
SPOOL = number BYTES ACCOUNT =
'account_ID'
FALLBACK NO
PROTECTION JOURNAL
NO
BEFORE
DUAL AFTER JOURNAL NO DUAL LOCAL NOT LOCAL DEFAULT JOURNAL TABLE =
table_name
database_name. DROP DEFAULT JOURNAL TABLE = table_name FF07D025
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 43
Chapter 3: SQL Data Definition Language Statement Syntax MODIFY PROFILE
MODIFY PROFILE MODIFY PROFILE
A
AS
profile_name
, A
ACCOUNT = (
'account_id' , 'account_id'
)
;
NULL DEFAULT DATABASE =
database_name NULL
SPOOL =
n BYTES NULL
TEMPORARY =
n BYTES NULL ,
PASSWORD
= ATTRIBUTES
(
EXPIRE =
n NULL
MINCHAR =
n NULL
MAXCHAR =
n NULL
DIGITS =
c NULL
SPECCHAR =
c NULL
MAXLOGONATTEMPTS = LOCKEDUSEREXPIRE = REUSE =
)
n NULL n NULL
n NULL NULL
3 – 44
Teradata RDBMS SQL/Data Dictionary Quick Reference
KZ01a002
Chapter 3: SQL Data Definition Language Statement Syntax MODIFY USER
MODIFY USER , MODIFY USER
username
AS PERMANENT
= number BYTES
PERM STARTUP =
NULL
quotestring PASSWORD =
password FOR USER RELEASE PASSWORD LOCK
TEMPORARY = number BYTES SPOOL = number BYTES
'account_ID'
ACCOUNT =
'account_ID'
(
,'account_ID'
)
DEFAULT DATABASE = database_name COLLATION = collation_sequence
FALLBACK PROTECTION
NO
JOURNAL NO
BEFORE
DUAL AFTER JOURNAL NO DUAL LOCAL NOT LOCAL
table_name
DEFAULT JOURNAL TABLE =
database_name DROP DEFAULT JOURNAL TABLE
= table_name TIME ZONE =
LOCAL
quotestring sign NULL DATEFORM =
INTEGERDATE ANSIDATE NULL
DEFAULT CHARACTER SET DEFAULT ROLE =
PROFILE =
character_data_type
role_name NONE NULL profile_name NULL
1101A008
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 45
Chapter 3: SQL Data Definition Language Statement Syntax RENAME MACRO RENAME PROCEDURE RENAME TABLE RENAME VIEW RENAME TRIGGER
RENAME MACRO RENAME PROCEDURE RENAME TABLE RENAME VIEW RENAME TRIGGER RENAME
old_name
MACRO TABLE
database_name.
TO
new_name ;
AS
VIEW TRIGGER PROCEDURE
3 – 46
FF07D159
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax SET ROLE
SET ROLE
SET ROLE
role_name NONE NULL
; KZ01A010
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 47
Chapter 3: SQL Data Definition Language Statement Syntax SET SESSION
SET SESSION Set Session Syntax SET SESSION SS
COLLATION
collation_sequence
ACCOUNT= 'account_id'
FOR
;
SESSION REQUEST
DATEFORM =
ANSIDATE INTEGERDATE
DATABASE
database_name 1101S141
Set Session Collation SET SESSION
COLLATION
collation_sequence ;
SS
FF07D291
Set Session Account SET SESSION SS
ACCOUNT='account_id'
FOR
SESSION REQUEST
; FF07D292
3 – 48
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 3: SQL Data Definition Language Statement Syntax SET SESSION
Set Session Dateform SET SESSION
DATEFORM=
SS
ANSIDATE INTEGERDATE
; FF07D293
Set Session Database SET SESSION
DATABASE
database_name ;
SS
1101A076
Teradata RDBMS SQL/Data Dictionary Quick Reference
3 – 49
Chapter 3: SQL Data Definition Language Statement Syntax SET TIME ZONE
SET TIME ZONE SET TIME ZONE
LOCAL INTERVAL
'time_zone_displacement'
HOUR TO MINUTE
;
sign USER FF07D143
3 – 50
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 4:
SQL Data Control Language Statement Syntax
Teradata RDBMS SQL/Data Dictionary Quick Reference
4–1
Chapter 4: SQL Data Control Language Statement Syntax GIVE
GIVE GIVE
database_name user_name
TO
recipient_name ; FF07A025
4–2
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 4: SQL Data Control Language Statement Syntax GRANT
GRANT SQL Form GRANT
ALL
TO ON
PRIVILEGES ,
database_name.object_name
privilege
object_name
,
PROCEDURE procedure_name
privilege
ALL BUT ,
A
database_name
25 user_name
A ALL
;
WITH GRANT OPTION
PUBLIC , 1101S055
role_name
MONITOR Form GRANT
MONITOR
TO
A
PRIVILEGES , BUT NOT
monitor_privilege
, monitor_privilege , A
user_name ALL PUBLIC
WITH GRANT OPTION
; FF07A056
Teradata RDBMS SQL/Data Dictionary Quick Reference
4–3
Chapter 4: SQL Data Control Language Statement Syntax GRANT
Role Form ,
, GRANT
role_name
TO
user_name role_name
WITH ADMIN OPTION
; KZ01a008
4–4
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 4: SQL Data Control Language Statement Syntax GRANT LOGON
GRANT LOGON , GRANT LOGON
ON
host_id
AS DEFAULT ,
ALL TO
WITH NULL PASSWORD
;
database_name
FROM FF07B027
Teradata RDBMS SQL/Data Dictionary Quick Reference
4–5
Chapter 4: SQL Data Control Language Statement Syntax REVOKE
REVOKE SQL Form REVOKE
A
ALL PRIVILEGES ,
GRANT OPTION FOR
privilege ALL BUT A
B ON
database_name object_type
database_name.object_name object_name ,
B
TO FROM
user_name ALL PUBLIC , role_name
4–6
FF07R061
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 4: SQL Data Control Language Statement Syntax REVOKE
MONITOR Form MONITOR
REVOKE GRANT OPTION FOR
TO
A
PRIVILEGES , BUT NOT
monitor_privilege
, monitor_privilege , A
TO FROM
user_name ALL PUBLIC
FF07A062
Role Form ,
, REVOKE
role_name ADMIN OPTION FOR
TO
user_name
FROM
role_name
; KZ01a009
Teradata RDBMS SQL/Data Dictionary Quick Reference
4–7
Chapter 4: SQL Data Control Language Statement Syntax REVOKE LOGON
REVOKE LOGON , REVOKE LOGON
ON
host_id
AS DEFAULT ,
ALL TO
;
database_name
FROM FF07A036
4–8
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 5:
Query and Workload Analysis Statements
Teradata RDBMS SQL/Data Dictionary Quick Reference
5–1
Chapter 5: Query and Workload Analysis Statements BEGIN QUERY LOGGING
BEGIN QUERY LOGGING A
BEGIN QUERY LOGGING , WITH
logging_option
LIMIT
limit_option AND
A
ON
limit_option
ALL , ,
;
user_name , ACCOUNT =
(
'account_name'
) 1101B109
5–2
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 5: Query and Workload Analysis Statements COLLECT DEMOGRAPHICS
COLLECT DEMOGRAPHICS
COLLECT
DEMOGRAPHICS
FOR
A
table_name , (
A
INTO
table_name
)
QCD_name ALL
;
WITH NO INDEX 1101A001
Teradata RDBMS SQL/Data Dictionary Quick Reference
5–3
Chapter 5: Query and Workload Analysis Statements COLLECT STATISTICS
COLLECT STATISTICS A
table_name
COLLECT STATISTICS COLLECT STATS
USING SAMPLE
ON
TEMPORARY
COLLECT STAT
join_index_name hash_index_name
A COLUMN
;
column_name ,
COLUMN
( column_name ) ,
INDEX
( column_name ) FF07D048
index_name
INDEX
CREATE INDEX Syntax , ,
COLLECT STATS
( column_name_1 )
INDEX
COLLECT STATISTICS USING SAMPLE
UNIQUE
index_name
A ( column_name_2 )
ORDER BY VALUES
COLLECT STAT
HASH COLUMN
column_name , (
A
ALL
ON
column_name
)
table_name ;
TEMPORARY join_index_name hash_index_name
5–4
Teradata RDBMS SQL/Data Dictionary Quick Reference
FF07D355
Chapter 5: Query and Workload Analysis Statements COLLECT STATISTICS (QCD Form)
COLLECT STATISTICS (QCD Form) COLLECT
STATISTICS
FOR SAMPLE
percentage
STATS
A PERCENT
STAT A
INTO
QCD_name
ON
B
table_name
B COLUMN COLUMN
;
column_name , (
column_name
INDEX
)
index_name ,
INDEX
(
column_name
) 1101B004
Teradata RDBMS SQL/Data Dictionary Quick Reference
5–5
Chapter 5: Query and Workload Analysis Statements DROP STATISTICS (Optimizer Form)
DROP STATISTICS (Optimizer Form) Recommended Syntax , A
DROP STATISTICS DROP STATS
COLUMN
column_name
FOR
DROP STAT
, COLUMN
(
column_name
)
INDEX UNIQUE
index_name INDEX
index_name
UNIQUE
B
A
, ( column_name_1 ) ( column_name_2
ORDER BY
)
VALUES HASH
table_name
B ON
;
TEMPORARY join_index_name hash_index_name
5–6
FF07D299
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 5: Query and Workload Analysis Statements DROP STATISTICS (Optimizer Form)
Legacy Syntax A
table_name
DROP STATISTICS ON
DROP STATS DROP STAT
TEMPORARY join_index_name hash_index_name
A COLUMN COLUMN
column_name_1 ,
;
( column_name_1 ) ,
INDEX ( column_name_2 ) INDEX
name
Teradata RDBMS SQL/Data Dictionary Quick Reference
FF07D029
5–7
Chapter 5: Query and Workload Analysis Statements DROP STATISTICS (QCD Form)
DROP STATISTICS (QCD Form) DROP
STATISTICS
FROM
QCD_name
ON
table_name
A
STATS STAT A COLUMN COLUMN INDEX
;
column_name , (
column_name
)
index_name ,
INDEX
(
column_name
) 1101B003
5–8
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 5: Query and Workload Analysis Statements DUMP EXPLAIN
DUMP EXPLAIN DUMP EXPLAIN
INTO
A
QCD_name LIMIT SQL =n
A
SQL_statement AS
query_plan_name
; 1101E321
Teradata RDBMS SQL/Data Dictionary Quick Reference
5–9
Chapter 5: Query and Workload Analysis Statements END QUERY LOGGING
END QUERY LOGGING END QUERY LOGGING
ON
ALL , ,
;
user_name , ACCOUNT =
(
'account_name'
( 1101B110
5 – 10
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 5: Query and Workload Analysis Statements INITIATE INDEX ANALYSIS
INITIATE INDEX ANALYSIS INITIATE INDEX ANALYSIS ON A
IN
QCD_name
AS
, table_name
index_name_tag SET
FOR
workload_name
, boundary_option = value
B
A
B
C KEEP INDEX
USE MODIFIED
STATISTICS STATS STAT
C CHECKPOINT
checkpoint_trigger
; 1101B013
Teradata RDBMS SQL/Data Dictionary Quick Reference
5 – 11
Chapter 5: Query and Workload Analysis Statements INSERT EXPLAIN
INSERT EXPLAIN INSERT EXPLAIN
A WITH
STATISTICS
AND DEMOGRAPHICS
NO INTO
A
QCD_name
, FOR
B AS
query_plan_name
table_name
B
SQL_statement FOR
LIMIT
frequency
;
SQL
1101E322
=n
5 – 12
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 5: Query and Workload Analysis Statements RESTART INDEX ANALYSIS
RESTART INDEX ANALYSIS
RESTART INDEX ANALYSIS
A
AS
FOR
workload_name
IN
QCD_name
A
index_name_tag ; 1101B111
Teradata RDBMS SQL/Data Dictionary Quick Reference
5 – 13
Chapter 5: Query and Workload Analysis Statements DIAGNOSTIC DUMP COSTS
DIAGNOSTIC DUMP COSTS DIAGNOSTIC
DUMP COSTS
target_system_name 'comment'
; FF07D327
5 – 14
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 5: Query and Workload Analysis Statements DIAGNOSTIC DUMP SAMPLES
DIAGNOSTIC DUMP SAMPLES DIAGNOSTIC
A
DUMP SAMPLES
target_system_name
A
table_name
TABLE database_name.
; GO01A001
Teradata RDBMS SQL/Data Dictionary Quick Reference
5 – 15
Chapter 5: Query and Workload Analysis Statements DIAGNOSTIC HELP COSTS
DIAGNOSTIC HELP COSTS DIAGNOSTIC
HELP COSTS ; FF07D328
5 – 16
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 5: Query and Workload Analysis Statements DIAGNOSTIC HELP SAMPLES
DIAGNOSTIC HELP SAMPLES
DIAGNOSTIC
HELP SAMPLES target_system_name
; GO01A002
Teradata RDBMS SQL/Data Dictionary Quick Reference
5 – 17
Chapter 5: Query and Workload Analysis Statements DIAGNOSTIC SET COSTS
DIAGNOSTIC SET COSTS DIAGNOSTIC
SET COSTS
target_system_name TPA NOT
ON FOR
REQUEST SESSION IFP
;
SYSTEM FF07D326
5 – 18
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 5: Query and Workload Analysis Statements DIAGNOSTIC SET SAMPLES
DIAGNOSTIC SET SAMPLES General Syntax DIAGNOSTIC
SET SAMPLES
target_system_name
ON FOR
A
NOT A
SESSION SYSTEM
TABLE
table_name ;
database_name.
GO01A004
Disable All Samples Syntax
DIAGNOSTIC SET ALL SAMPLES NOT ON FOR
SESSION SYSTEM
; GO01A003
Teradata RDBMS SQL/Data Dictionary Quick Reference
5 – 19
Chapter 5: Query and Workload Analysis Statements DIAGNOSTIC “Validate Index”
DIAGNOSTIC “Validate Index” DIAGNOSTIC
"validate index"
ON
FOR
SESSION
NOT
; TW01A002
5 – 20
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 6:
SQL Help and Database Object Definition Tools: HELP and SHOW
Teradata RDBMS SQL/Data Dictionary Quick Reference
6–1
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP
HELP HELP
DATABASE
database_name
USER
;
user_name
TABLE
table_name join_index_name
VOLATILE TABLE VIEW
view_name
MACRO
macro_name ,
COLUMN
, FROM ,
column_name
COLUMN
*
FROM
table_name
table_name. ,
COLUMN
table_name.column_name
COLUMN
table_name. *
COLUMN
expression INDEX
table_name
TEMPORARY
,
join_index_name
JOIN INDEX
join_index_name
HASH INDEX
hash_index_name STATISTICS
( column_name )
table_name
TEMPORARY HELP
STATISTICS STATS
table_name
FROM
QCD_name
STAT SESSION CONSTRAINT
table_name.name database_name.
TRIGGER
database_name.
trigger_name table_name
procedure_name
PROCEDURE
database_name.
ATTRIBUTES ATTR ATTRS 1101F022
6–2
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP (Online Form)
HELP (Online Form) HELP
' HELP
' ;
' SQL
commandname ' ARCHIVE
commandname ' DUMP
commandname ' FASTEXPORT
commandname ' FASTLOAD
commandname ' MULTILOAD
commandname ' PMPC
commandname ' TPCCONS
commandname ' SPL
commandname
1101A006
Teradata RDBMS SQL/Data Dictionary Quick Reference
6–3
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP COLUMN
HELP COLUMN Syntax 1 , HELP COLUMN
,
column_name
FROM
table_name ;
join_index_name
FF07D244
hash_index_name
Syntax 2 , HELP COLUMN
*
FROM
table_name. ;
join_index_name
FF07D245
hash_index_name
Syntax 3 , HELP COLUMN
table_name. column_name ;
join_index_name hash_index_name
FF07D246
Syntax 4 HELP COLUMN
table_name.* ;
join_index_name hash_index_name
FF07D247
Syntax 5 HELP COLUMN
expression ; FF07D264
6–4
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP CONSTRAINT
HELP CONSTRAINT table_name. constraint_name
HELP CONSTRAINT database_name.
; FF07D248
Teradata RDBMS SQL/Data Dictionary Quick Reference
6–5
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP DATABASE HELP USER
HELP DATABASE HELP USER HELP
DATABASE
database_name
USER
user_name
; FF07D240
6–6
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP HASH INDEX
HELP HASH INDEX HELP HASH INDEX
hash_index_name ; 1101A005
Teradata RDBMS SQL/Data Dictionary Quick Reference
6–7
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP INDEX
HELP INDEX HELP
INDEX TEMPORARY
table_name join_index_name
;
;
( column_name ) FF07D002
6–8
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP JOIN INDEX
HELP JOIN INDEX
HELP JOIN INDEX
join_index_name ; FF07D047
Teradata RDBMS SQL/Data Dictionary Quick Reference
6–9
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP MACRO HELP TABLE HELP VIEW
HELP MACRO HELP TABLE HELP VIEW HELP
MACRO TABLE
macro_name table_name
;
joint_index_name VIEW
view_name FF07D241
6 – 10
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP PROCEDURE
HELP PROCEDURE HELP PROCEDURE
procedure_name database_name.
ATTRIBUTES
;
ATTR ATTRS YSHP004
Teradata RDBMS SQL/Data Dictionary Quick Reference
6 – 11
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP SESSION
HELP SESSION HELP SESSION ; FF07D242
6 – 12
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP STATISTICS (Optimizer Form)
HELP STATISTICS (Optimizer Form) HELP TEMPORARY
STATISTICS
table_name
STATS
join_index_name
STAT
hash_index_name
Teradata RDBMS SQL/Data Dictionary Quick Reference
; FF07D243
6 – 13
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP STATISTICS (QCD Form)
HELP STATISTICS (QCD Form)
HELP
STATISTICS STATS
table_name
FROM
QCD_name ;
STAT 1101B005
6 – 14
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP TRIGGER
HELP TRIGGER HELP TRIGGER
trigger_name database_name
table_name
; FF07D038
Teradata RDBMS SQL/Data Dictionary Quick Reference
6 – 15
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW HELP VOLATILE TABLE
HELP VOLATILE TABLE HELP VOLATILE TABLE
table_name ; FF07D249
6 – 16
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW SHOW
SHOW SHOW
dml_statement QUALIFIED
; KO01A012
Teradata RDBMS SQL/Data Dictionary Quick Reference
6 – 17
Chapter 6: SQL Help and Database Object Definition Tools: HELP and SHOW SHOW JOIN INDEX SHOW MACRO SHOW PROCEDURE SHOW TABLE SHOW TRIGGER SHOW VIEW
SHOW JOIN INDEX SHOW MACRO SHOW PROCEDURE SHOW TABLE SHOW TRIGGER SHOW VIEW SHOW
HASH INDEX
hash_index_name
JOIN INDEX
join_index_name
MACRO
;
macro_name TABLE
table_name
TEMPORARY TRIGGER VIEW
trigger_name view_name
PROCEDURE
procedure_name database_name.
FF07D024
Embedded SQL Syntax SHOW
MACRO TABLE
object_name
INTO
A
dbname.
VIEW A
host_variable_name :
: host_indicator_name INDICATOR GW01A034
6 – 18
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 7:
SQL Client-Server Connectivity Statements
Teradata RDBMS SQL/Data Dictionary Quick Reference
7–1
Chapter 7: SQL Client-Server Connectivity Statements CONNECT
CONNECT CONNECT
idvar
IDENTIFIED BY
:
passwordvar
A
:
A AS
connection_name : namevar
7–2
JR01A002
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 7: SQL Client-Server Connectivity Statements GET CRASH
GET CRASH
GET CRASH
WAIT, TELL
INTO
waitvar, :
tellvar, : GW01A058
Teradata RDBMS SQL/Data Dictionary Quick Reference
7–3
Chapter 7: SQL Client-Server Connectivity Statements LOGOFF
LOGOFF LOGOFF CURRENT ALL connection_name : host_variable_name
7–4
JR01A004
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 7: SQL Client-Server Connectivity Statements LOGON
LOGON LOGON
logon_string :
AS
connection_name : namevar
JR01A003
Teradata RDBMS SQL/Data Dictionary Quick Reference
7–5
Chapter 7: SQL Client-Server Connectivity Statements SET BUFFERSIZE
SET BUFFERSIZE SET BUFFERSIZE
size
GW01A032
7–6
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 7: SQL Client-Server Connectivity Statements SET CHARSET
SET CHARSET
SET CHARSET
set_name :set_name_var GW01A033
Teradata RDBMS SQL/Data Dictionary Quick Reference
7–7
Chapter 7: SQL Client-Server Connectivity Statements SET CONNECTION
SET CONNECTION
SET CONNECTION
connection_name : namevar JR01A005
7–8
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 7: SQL Client-Server Connectivity Statements SET CRASH
SET CRASH
SET CRASH
WAIT_NOTELL NOWAIT_TELL GW01A057
Teradata RDBMS SQL/Data Dictionary Quick Reference
7–9
Chapter 7: SQL Client-Server Connectivity Statements SET CRASH
7 – 10
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 8:
The SELECT Statement
Teradata RDBMS SQL/Data Dictionary Quick Reference
8–1
Chapter 8: The SELECT Statement SELECT
SELECT SELECT SEL
A
* ,
DISTINCT ALL
expression alias_name AS table_name.* ,
A FROM
table_name
B Single Tables
alias_name AS join_table_name
JOIN
joined_table
ON
search_condition
INNER LEFT RIGHT OUTER FULL CROSS JOIN ( subquery )
Joined Tables
derived_table_name AS (
B WHERE search_condition GROUP BY
8–2
Derived Tables
,
, column_name column_position expression
column_name
) C
HAVING conditional_expression QUALIFY search_condition
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 8: The SELECT Statement SELECT
C
D
SAMPLE WITH REPLACEMENT
RANDOMIZED ALLOCATION
, fraction_description
D
E
count_description
, WHEN
condition
THEN
fraction_description
F
count_description E ORDER BY
F
, ELSE
, expression column_name column_position
G ASC DESC
END
fraction_description count_description
G WITH
;
, expression_1 BY
, expression_2 ASC DESC 1101S080
Teradata RDBMS SQL/Data Dictionary Quick Reference
8–3
Chapter 8: The SELECT Statement SELECT
Simple SELECT Statement , SELECT SEL
expression
FROM column_name *
8–4
table_name ; FF06R024
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 8: The SELECT Statement SELECT INTO
SELECT INTO Embedded SQL Form SELECT
select_list
SEL
A
INTO
ALL DISTINCT ,
A
B
host_variable_name :
:host_indicator_name INDICATOR
B
from_clause where_clause GW01A048
Stored Procedures Form SELECT SEL
select_list
INTO
C
ALL DISTINCT ,
C
: local_variable_name : parameter_name
from_clause where_clause ff07D406
Teradata RDBMS SQL/Data Dictionary Quick Reference
8–5
Chapter 8: The SELECT Statement SELECT INTO
DISTINCT and ALL Options DISTINCT ALL FF06A018
FROM Clause , FROM
table_name Single Tables
correlation_name AS joined_table
JOIN joined_table ON search_condition INNER LEFT RIGHT FULL
CROSS JOIN ( subquery )
Joined Tables
OUTER single_table
derived_table_name
,
AS (
column_name
)
Derived Tables FF06A013
WHERE Clause WHERE search_condition FF06R011
8–6
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 8: The SELECT Statement Subqueries in Search Conditions
Subqueries in Search Conditions Syntax 1 comparison_operator
expression , (
expression
)
(query )
IN
ANY
NOT IN
SOME ALL HH01B064
Syntax 2: Logical Expressions
EXISTS
(query ) HH01A065
Teradata RDBMS SQL/Data Dictionary Quick Reference
8–7
Chapter 8: The SELECT Statement Clauses
Clauses GROUP BY Clause , GROUP BY
column_name column_position expression FF06R015
HAVING Clause HAVING condition FF06R016
QUALIFY Clause QUALIFY
search_condition FF07D087
8–8
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 8: The SELECT Statement Clauses
SAMPLE Clause A
SAMPLE WITH REPLACEMENT
RANDOMIZED ALLOCATION
, fraction_description
A
B
count_description
, WHEN
condition
THEN
fraction_description
C
count_description
B
C
, ELSE
END
fraction_description count_description 1101A065
SAMPLEID Expression SAMPLEID FF07D180
Teradata RDBMS SQL/Data Dictionary Quick Reference
8–9
Chapter 8: The SELECT Statement Clauses
ORDER BY Clause , expression
ORDER BY
column_name column_position
ASC DESC
FF06R017
WITH Clause , WITH
expression_1 , BY
expression_2 ASC DESC
8 – 10
FF06B014
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9:
SQL Data Manipulation Language Statement Syntax
Teradata RDBMS SQL/Data Dictionary Quick Reference
9–1
Chapter 9: SQL Data Manipulation Language Statement Syntax ABORT
ABORT ABORT abort_message
FROM option
WHERE abort_condition FF07R068
9–2
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax ASYNC Statement Modifier
ASYNC Statement Modifier
ASYNC
(
async_statement_modifier
)
async_SQL_statement
:host_variable_name JR01A001
Teradata RDBMS SQL/Data Dictionary Quick Reference
9–3
Chapter 9: SQL Data Manipulation Language Statement Syntax BEGIN DECLARE SECTION
BEGIN DECLARE SECTION
BEGIN DECLARE SECTION GW01A001
9–4
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax BEGIN TRANSACTION
BEGIN TRANSACTION
BEGIN TRANSACTION BT GW01A040
Teradata RDBMS SQL/Data Dictionary Quick Reference
9–5
Chapter 9: SQL Data Manipulation Language Statement Syntax CALL
CALL , CALL
procedurename
(
)
dbname .
IN argument
;
INOUT argument OUT argument
IN argument value expression ?
INOUT argument value expression ?
OUT argument out_call_variable OUT call placeholder
OUT call placeholder param-name CAST
(
OUT call placeholder
AS
data type
) YSCALL001
9–6
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax CHECKPOINT
CHECKPOINT Interactive Syntax tname
CHECKPOINT
;
, NAMED chkpt_name
FF07A007
Embedded SQL and Stored Procedure Syntax table_name
CHECKPOINT dbname.
A ,NAMED
ckpt_label : lablevar
A
INTO
host_variable_name
B
: B : host_indicator_name INDICATOR
Teradata RDBMS SQL/Data Dictionary Quick Reference
GW01A002
9–7
Chapter 9: SQL Data Manipulation Language Statement Syntax COMMENT
COMMENT Placing Form COMMENT
objkind
objref
AS
'comment '
IS
ON
GW01A004
Returning Form COMMENT
objkind
objref
INTO
A
ON A
host_variable_name
B
: B :host_indicator_name INDICATOR GW01A005
9–8
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax COMMIT
COMMIT COMMIT WORK RELEASE GW01A006
Teradata RDBMS SQL/Data Dictionary Quick Reference
9–9
Chapter 9: SQL Data Manipulation Language Statement Syntax DATABASE
DATABASE
DATABASE
dbname :dbnamevar GW01A008
9 – 10
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax DECLARE STATEMENT
DECLARE STATEMENT , DECLARE
statement_name
STATEMENT GW01A013
Teradata RDBMS SQL/Data Dictionary Quick Reference
9 – 11
Chapter 9: SQL Data Manipulation Language Statement Syntax DECLARE TABLE
DECLARE TABLE DECLARE
table_name
A
TABLE
view_name , A
( column_name
data_type
) null_attribute GW01R014
9 – 12
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax DELETE
DELETE Basic/Searched Form DELETE DEL
A
table_name FROM
table_name
correlation_name AS
A WHERE
;
condition
ALL 1101C072
Join Condition Form DELETE
delete_table_name
A
table_name
DEL
correlation_name AS
A WHERE
condition
;
ALL 1101C073
Teradata RDBMS SQL/Data Dictionary Quick Reference
9 – 13
Chapter 9: SQL Data Manipulation Language Statement Syntax DELETE
DELETE DEL
FROM
A
table_name
delete_table_name
correlation_name AS
A WHERE
condition
;
ALL 1101C074
Positioned Form DELETE
FROM table_name
WHERE CURRENT OF
cursor_name
DEL GW01A046
9 – 14
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax DESCRIBE
DESCRIBE DESCRIBE
statement_name
A
INTO :
A
B
descriptor_area USING
NAMES ANY BOTH LABELS
B FOR STATEMENT
statement_number numvar :
Teradata RDBMS SQL/Data Dictionary Quick Reference
GW01A015
9 – 15
Chapter 9: SQL Data Manipulation Language Statement Syntax ECHO
ECHO '
ECHO '
string
;
' '
command ;
9 – 16
Teradata RDBMS SQL/Data Dictionary Quick Reference
FF07R022
Chapter 9: SQL Data Manipulation Language Statement Syntax END DECLARE SECTION
END DECLARE SECTION
END DECLARE SECTION
GW01A016
Teradata RDBMS SQL/Data Dictionary Quick Reference
9 – 17
Chapter 9: SQL Data Manipulation Language Statement Syntax END-EXEC Statement Terminator
END-EXEC Statement Terminator END-EXEC . FF07D287
9 – 18
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax END TRANSACTION
END TRANSACTION
END TRANSACTION ET
GW01A041
Teradata RDBMS SQL/Data Dictionary Quick Reference
9 – 19
Chapter 9: SQL Data Manipulation Language Statement Syntax EXEC
EXEC
EXEC
macroname (parameter_list )
9 – 20
GW01A043
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax EXEC SQL Statement Prefix
EXEC SQL Statement Prefix
EXEC SQL
embedded_sql_statement
sql_statement_terminator FF07D288
Teradata RDBMS SQL/Data Dictionary Quick Reference
9 – 21
Chapter 9: SQL Data Manipulation Language Statement Syntax EXECUTE
EXECUTE Macro Form macroname
EXECUTE EXEC
,
;
( param_name = const_expr , (
const_expr
)
) FF07A023
Dynamic SQL Form EXECUTE
A
statement_name
A , USING
host_variable_name :
:host_indicator_name INDICATOR
USING DESCRIPTOR
descriptor_area : GW01A017
9 – 22
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax EXECUTE IMMEDIATE
EXECUTE IMMEDIATE
EXECUTE IMMEDIATE
statement_string statement_string_var :
Teradata RDBMS SQL/Data Dictionary Quick Reference
GW01A018
9 – 23
Chapter 9: SQL Data Manipulation Language Statement Syntax EXPLAIN Modifier
EXPLAIN Modifier EXPLAIN
SQL _statement ; FF07D251
9 – 24
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax INCLUDE
INCLUDE Syntax INCLUDE
text_name
GW01A020
SQLCA INCLUDE SQLCA GW01A021
SQLDA INCLUDE SQLDA
GW01A022
Teradata RDBMS SQL/Data Dictionary Quick Reference
9 – 25
Chapter 9: SQL Data Manipulation Language Statement Syntax INSERT
INSERT , INSERT INS
table_name INTO
(
expression
)
VALUES ,
;
,
( column_name ) VALUES
)
subquery
, ( column_name
( expression
)
DEFAULT VALUES FF07B030
9 – 26
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax LOCKING Modifier
LOCKING Modifier database_name
LOCKING LOCK
DATABASE table_name TABLE
IN
EXCLUSIVE
A MODE
NOWAIT
EXCL SHARE
view_name VIEW ROW A
ACCESS FOR
READ WRITE CHECKSUM
statement ; FF07R031
Teradata RDBMS SQL/Data Dictionary Quick Reference
9 – 27
Chapter 9: SQL Data Manipulation Language Statement Syntax MERGE
MERGE MERGE
A
target_table correlation_name
INTO AS , A
USING
VALUES
(
using_expression (
subquery
B
( (
AS
, B
source_table_name
(
column_name
(
ON
C
match_condition ,
C
WHEN MATCHED THEN
UPDATE
SET
D
update_column=update_expression
UPD E
WHEN NOT MATCHED clause
D ;
WHEN NOT MATCHED clause E
WHEN NOT MATCHED clause , WHEN NOT MATCHED THEN
(
INSERT INS
insert_expression
)
VALUES , (
insert_column
)
VALUES 1101B012
9 – 28
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax PREPARE
PREPARE PREPARE
A1
statement_name
A2
descriptor_area
INTO : A1
B
A2 USING
NAMES
FOR STATEMENT
statement_number numvar
ANY :
BOTH LABELS B
FROM
statement_string statement_string_var :
Teradata RDBMS SQL/Data Dictionary Quick Reference
GW01A029
9 – 29
Chapter 9: SQL Data Manipulation Language Statement Syntax ROLLBACK
ROLLBACK A
ROLLBACK WORK
'abort_message' RELEASE
A FROM_clause
WHERE_clause
; GW01R031
9 – 30
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax TEST
TEST
TEST
async_statement_identifier : namevar
COMPLETION JR01A007
Teradata RDBMS SQL/Data Dictionary Quick Reference
9 – 31
Chapter 9: SQL Data Manipulation Language Statement Syntax UPDATE
UPDATE Searched Form UPDATE
table_name
A
UPD
alias_name AS , FROM
table_name alias_name AS
, A
SET
column_name = expression ;
ALL WHERE
condition FF07B040
Positioned Form , UPDATE UPD A
SET
table_name
A
column_name = expression
alias_name WHERE CURRENT OF
cursor_name ; GW01A047
9 – 32
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax UPDATE
Upsert Form , UPDATE
table_name_1
SET
column_name=expression
A
UPD ELSE
A WHERE B
INSERT
condition (
INS
expression
table_name_2
) ;
VALUES , (
B
INTO
column_name
)
VALUES
(
expression
)
DEFAULT VALUES FF07D378
Teradata RDBMS SQL/Data Dictionary Quick Reference
9 – 33
Chapter 9: SQL Data Manipulation Language Statement Syntax USING Row Descriptor
USING Row Descriptor , USING
host_variable_name
(
)
data_type_declaration
A
data_type_attribute A
SQL_request ; 1101E201
9 – 34
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 9: SQL Data Manipulation Language Statement Syntax WAIT
WAIT , WAIT
async_statement_identifier ALL
COMPLETION
ANY COMPLETION INTO
stmtvar :
,
sessvar :
Teradata RDBMS SQL/Data Dictionary Quick Reference
JR01A008
9 – 35
Chapter 9: SQL Data Manipulation Language Statement Syntax WHENEVER
WHENEVER WHENEVER
condition
action GW01R035
9 – 36
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 10:
SQL Stored Procedures
Teradata RDBMS SQL/Data Dictionary Quick Reference
10 – 1
Chapter 10: SQL Stored Procedures BEGIN - END Statement
BEGIN - END Statement BEGIN label_name :
A local_declaration
A
cursor_declaration END
condition_handler
statement
; label_name YS6BE001
10 – 2
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 10: SQL Stored Procedures CASE
CASE Syntax 1
CASE
operand_1
WHEN
operand_2
A
THEN
A
statement
END CASE
;
statement
ELSE
YSCase01
Syntax 2
CASE
WHEN
conditional_expression
A
THEN END CASE
ELSE
A
statement ;
statement YSCase02
Teradata RDBMS SQL/Data Dictionary Quick Reference
10 – 3
Chapter 10: SQL Stored Procedures DECLARE
DECLARE , DECLARE
variable_name
data_type
; attribute
DEFAULT
literal NULL YS6DE001
10 – 4
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 10: SQL Stored Procedures DECLARE HANDLER
DECLARE HANDLER DECLARE
CONTINUE
HANDLER
FOR
A
EXIT , A
SQLSTATE
sqlstate_code
handler_action_statement
;
VALUE , SQLEXCEPTION SQLWARNING NOT FOUND
Teradata RDBMS SQL/Data Dictionary Quick Reference
YS6DH001
10 – 5
Chapter 10: SQL Stored Procedures FOR
FOR FOR
for_loop_variable
label_name : A
cursor_specification
A
AS cursor_name
DO
statement
CURSOR FOR
END FOR
; label_name YS6FOR01
10 – 6
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 10: SQL Stored Procedures IF
IF IF
conditional_expression
THEN
A
statement
A
B ELSEIF
conditional_expression
THEN END IF
B ELSE
statement
statement ; YS6IF001
Teradata RDBMS SQL/Data Dictionary Quick Reference
10 – 7
Chapter 10: SQL Stored Procedures ITERATE
ITERATE
ITERATE
label_name
; YS6ITER01
10 – 8
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 10: SQL Stored Procedures LEAVE
LEAVE
LEAVE
label_name
; YS6LEA01
Teradata RDBMS SQL/Data Dictionary Quick Reference
10 – 9
Chapter 10: SQL Stored Procedures LOOP
LOOP
LOOP label_name :
statement
END LOOP
; label_name YS6LOOP1
10 – 10
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 10: SQL Stored Procedures REPEAT
REPEAT REPEAT
statement
A
UNTIL
label_name : A
conditional_expression
END REPEAT
; label_name YS6RPT01
Teradata RDBMS SQL/Data Dictionary Quick Reference
10 – 11
Chapter 10: SQL Stored Procedures SET
SET
SET
assignment_target =
assignment_source
; YS6SET01
10 – 12
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 10: SQL Stored Procedures WHILE
WHILE WHILE
conditional_expression
A
DO
label_name : A
statement
END WHILE
; label_name
YS6WHI01
Teradata RDBMS SQL/Data Dictionary Quick Reference
10 – 13
Chapter 10: SQL Stored Procedures WHILE
10 – 14
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 11:
Cursors and Cursor Control Statements
Teradata RDBMS SQL/Data Dictionary Quick Reference
11 – 1
Chapter 11: Cursors and Cursor Control Statements CLOSE
CLOSE CLOSE
cursor_name GW01A003
11 – 2
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 11: Cursors and Cursor Control Statements DECLARE CURSOR
DECLARE CURSOR Dynamic SQL Form DECLARE
cursor_name
CURSOR FOR
statement_name
GW01A012
Macro Form DECLARE
cursor_name
A
CURSOR FOR EXEC dbname.
macroname
A
( parameter_list ) GW01A011
Request Form DECLARE
cursor_name
CURSOR FOR
'request_specification' GW01A010
Selection Form DECLARE A
cursor_name
A
CURSOR FOR
COMMENT EXPLAIN HELP SHOW SELECT GW01C009
Teradata RDBMS SQL/Data Dictionary Quick Reference
11 – 3
Chapter 11: Cursors and Cursor Control Statements DECLARE CURSOR
Stored Procedures Form DECLARE
CURSOR FOR
cursor_name
cursor_specification
A
NO SCROLL SCROLL ;
A FOR
READ ONLY UPDATE 1101A072
11 – 4
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 11: Cursors and Cursor Control Statements FETCH
FETCH Embedded SQL Form FETCH
A
cursor_name
A , INTO
host_variable_name :
: host_indicator_name INDICATOR
USING DESCRIPTOR
descriptor_area :
GW01A019
Stored Procedures Form FETCH
cursor_name
INTO
A
FROM NEXT FIRST , A
local_variable_name
;
parameter_reference 1101A074
Teradata RDBMS SQL/Data Dictionary Quick Reference
11 – 5
Chapter 11: Cursors and Cursor Control Statements OPEN
OPEN Embedded SQL Form OPEN
A
cursor_name
A , USING
host_variable_name :
:host_indicator_name INDICATOR
USING DESCRIPTOR
descriptor_area : GW01A027
Stored Procedures Form
OPEN
cursor_name
; 1101A073
11 – 6
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 11: Cursors and Cursor Control Statements POSITION
POSITION POSITION
cursor_name TO NEXT TO
statement_number STATEMENT
numvar :
Teradata RDBMS SQL/Data Dictionary Quick Reference
GW01A028
11 – 7
Chapter 11: Cursors and Cursor Control Statements REWIND
REWIND REWIND
cursor_name
GW01A030
11 – 8
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12:
Data Dictionary Views
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 1
Chapter 12: Data Dictionary Views View Definitions
View Definitions Views shown with an [X] suffix have two modes. • •
12 – 2
Without the X (for example, DBC.AccountInfo), they display global information. With the X (for example, DBC.AccountInfoX), they display information associated with the requesting user only.
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.AccessLog User Type
Security Administrator
Columns Selected
LogDate LogTime LogonDate LogonTime LogicalHostId IFPNo SessionNo UserName AccountName OwnerName AccessType Frequency EventCount Result DatabaseName TVMName ColumnName StatementType StatementText
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 3
Chapter 12: Data Dictionary Views View Definitions
DBC.AccLogRules User Type
Security Administrator
Columns Selected
UserName DatabaseName TVMName AcrAlterFunction AcrCheckpoint AcrCreateDatabase AcrCreateFunction AcrCreateMacro AcrCreateProcedure AcrCreateTable AcrCreateUser AcrCreateView AcrDelete AcrDropDatabase AcrDropFunction AcrDropMacro AcrDropProcedure AcrDropTable AcrDropUser AcrDropView AcrDump
12 – 4
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.AccLogRules (continued) User Type
Security Administrator
Columns Selected
AcrExecute AcrExecuteFunction AcrExecuteProcedure AcrGrant AcrIndex AcrInsert AcrReference AcrRestore AcrSelect AcrUpdate ArcCreateTrigger ArcDropTrigger AcrCreateRole AcrDropRole AcrCreateProfile AcrDropProfile AcrAlterProcedure CreatorName CreateTimeStamp
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 5
Chapter 12: Data Dictionary Views View Definitions
DBC.AccountInfo[X] User Type
Columns Selected
Supervisory
Name
[X]End
UserOrProfile
Administrator
AccountName
DBC.AllRights User Type
Administrator
Columns Selected
UserName DatabaseName TableName ColumnName AccessRight GrantAuthority GrantorName AllnessFlag CreatorName CreateTimeStamp
12 – 6
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.AllRoleRights User Type
Columns Selected
Security Administrator
UserName
Supervisory
DatabaseName
Administrator
TableName ColumnName AccessRight GrantAuthority GrantorName CreateTimeStamp
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 7
Chapter 12: Data Dictionary Views View Definitions
DBC.AllSpace[X] User Type
Columns Selected
Administrator
Vproc
[X]End
DatabaseName AccountName TableName MaxPerm MaxSpool MaxTemp CurrentPerm CurrentSpool CurrentTemp PeakPerm PeakSpool PeakTemp
DBC.AllTempTables[X] User Type
Columns Selected
Administrator
HostNo
[X]End
SessionNo UserName B_DatabaseName B_TableName E_TableId
12 – 8
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.All_RI_Children User Type
All users
Columns Selected
IndexID IndexName ChildDB ChildTable ChildKeyColumn ParentDB ParentTable ParentKeyColumn InconsistencyFlag CreatorName CreateTimeStamp
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 9
Chapter 12: Data Dictionary Views View Definitions
DBC.All_RI_Parents User Type
All users
Columns Selected
IndexID IndexName ParentDB ParentTable ParentKeyColumn ChildDB ChildTable ChildKeyColumn InconsistencyFlag CreatorName CreateTimeStamp
DBC.AMPUsage User Type
Administrator
Columns Selected
AccountName UserName CPUTime Vproc VprocType Model DiskIO
12 – 10
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.Association User Type
Operations Control
Columns Selected
DatabaseName TableName EventNum Original_DataBaseName Original_TableName Original_TableKind Original_Version Original_ProtectionType Original_JournalFlag Original_CreatorName Original_CommentString
DBC.CharSets User Type
End
Columns Selected
CharSetName
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 11
Chapter 12: Data Dictionary Views View Definitions
DBC.CharTranslations User Type
End
Columns Selected
CharSetName CharSetId InstallFlag E2I E2IUp I2E I2EUp
DBC.Children[X] User Type
Administrator
Columns Selected
Child Parent
DBC.Collations User Type
Columns Selected
End
CollName
Administrator
CollInstall CollEqvClass CollOrderCS CollOrderUC
12 – 12
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.Columns[X] User Type
Columns Selected
[X]End
DatabaseName
Administrator
TableName ColumnName ColumnFormat ColumnTitle SPParameterType ColumnType ColumnLegth DefaultValue Nullable CommentString DecimalTotalDigits DecimalFractionalDigits ColumnId UpperCaseFlag Compressible CompressValue ColumnConstraint ConstraintCount CreatorName CreateTimeStamp LastAlterName LastAlterTimeStamp CharType
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 13
Chapter 12: Data Dictionary Views View Definitions
DBC.Columns[X] (continued) User Type
Columns Selected
[X]End
IdColType
Administrator
CompressValueList
NOTE:
AccessCount**
** This field is not used.
LastAccessTimeStamp**
DBC.ColumnStats User Type
Tools
Columns Selected
DatabaseNameI FieldID FieldFormat FieldName FieldStatistics FieldType ImpliedPoint MaxLength TotalDigits TVMNameI
12 – 14
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.Databases[X] User Type
Columns Selected
[X]End
DatabaseName
Administrator
CreatorName
NOTE:
OwnerName
**This field is not used.
AccountName ProtectionType JournalFlag PermSpace SpoolSpace TempSpace CommentString CreateTimeStamp LastAlterName LastAlterTimeStamp DBKind AccessCount** LastAccessTimeStamp**
DBC.Databases2 User Type
All users
Columns Selected
DatabaseName DatabaseId UnResolvedRICount
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 15
Chapter 12: Data Dictionary Views View Definitions
DBC.Database_Default_Journals[X] User Type
Columns Selected
[X]End
DatabaseName
Administrator
Journal_DB JournalName
DBC.DBCInfo User Type
All users
Columns Selected
InfoKey InfoData
12 – 16
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.DBQLRules User Type
Columns Selected
Administrator
UserName
Supervisory
AccountString ExplainFlag ObjFlag SqlFlag StepFlag SummaryFlag ThresholdFlag TextSizeLimit SummaryVal1 SummaryVal2 SummaryVal3 ThreshValue
DBC.DeleteAccessLog[X] User Type
Columns Selected
Security
LogDate
Administrator
LogTime
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 17
Chapter 12: Data Dictionary Views View Definitions
DBC.DeleteOldInDoubt User Type
Administrator
Columns Selected
LogicalHostId CoordTaskId LogonUserName CommitOrRollback CompletionDate UserLogonTime SessionNumber RunUnitId ResolvingUserLogonName UserLogonDate CompletionTime Options
12 – 18
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.DiskSpace[X] User Type
Columns Selected
Administrator
Vproc
[X]End
DatabaseName
Supervisory
AccountName MaxPerm MaxSpool MaxTemp CurrentPerm CurrentSpool CurrentTemp PeakPerm PeakSpool PeakTemp
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 19
Chapter 12: Data Dictionary Views View Definitions
DBC.Events[X] User Type
Operations Control
Columns Selected
CreateDate CreateTime EventNum EventType UserName DatabaseName ObjectType AllAMPsFlag RestartSeqNum OperationInProcess TableName CheckpointName LinkingEventNum DataSetName LockMode JournalUsed JournalSaved IndexPresent DupeDumpSet
12 – 20
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.Events_Configuration[X] User Type
Operations Control
Columns Selected
Vproc CreateDate CreateTime EventNum EventType UserName LogProcessor PhyProcessor ProcessorState RestartSeqNum
DBC.Events_Media[X] User Type
Operations Control
Columns Selected
CreateDate CreateTime EventNum EventType UserName DataSetName VolSerialId VolSequenceNum DupeDumpSet
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 21
Chapter 12: Data Dictionary Views View Definitions
DBC.Functions User Type
Administrator
Columns Selected
DatabaseName FunctionName SpecificName FunctionId NumParameters ParameterDataTypes FunctionType ExternalName SrcFileLanguage NoSQLDataAccess ParameterStyle DeterministicOpt NullCall PrepareCount ExecProtectionMode ExtFileReference CharacterType Platform
12 – 22
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.Hardware_Event_Log User Type
Operations Control
Columns Selected
TheDate TheTime Event_Tag Category Severity Primary_Part_Number Revision_Level Secondary_Part_Number Serial_Number PMA Module_Type Slot Slot_Type SubSlot SubSlot_Type FW_Version Vcc_Margin Frequency_Margin Vcc_Volts Vcc_Amps Temperature Line Text Error_Data
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 23
Chapter 12: Data Dictionary Views View Definitions
DBC.HostsInfo User Type
Columns Selected
End
LogicalHostId
Administrator
HostName DefaultCharSet
DBC.IndexConstraints User Type
Columns Selected
End
DatabaseName
Administrator
TableName IndexName IndexNumber ConstraintType ConstraintText ConstraintCollation CollationName CreatorName CreateTimestamp
12 – 24
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.IndexStats User Type
Tools
Columns Selected
DatabaseNameI FieldFormat FieldName FieldPosition FieldType ImpliedPoint IndexNumber IndexType IndexStatistics MaxLength Name TotalDigits TVMNameI UniqueFlag
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 25
Chapter 12: Data Dictionary Views View Definitions
DBC.Indices[X] User Type
Columns Selected
Supervisory
DatabaseName
[X]End
TableName
Administrator
IndexNumber
NOTE:
IndexType
**This field is not used.
UniqueFlag IndexName ColumnName ColumnPosition CreatorName CreateTimeStamp LastAlterName LastAlterTimeStamp IndexMode AccessCount** LastAccessTimeStamp**
12 – 26
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.InDoubtLog User Type
Administrator
Columns Selected
LogicalHostId CoordTaskId LogonUserName UserLogonDate CompletionDate CommitOrRollBack SessionNumber RunUnitId ResolvingUserLogonName UserLogonTime CompletionTime Options
DBC.Journals[X] User Type
Columns Selected
[X]End
Tables_DB
Administrator
TableName Journals_DB JournalName
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 27
Chapter 12: Data Dictionary Views View Definitions
DBC.LogOnOff User Type
Columns Selected
Security Administrator
LogDate
Administrator
LogTime
Supervisory
UserName AccountName Event LogicalHostId IFPNo SessionNo LogonDate LogonTime LogonSource
DBC.LogonRules User Type
Administrator
Columns Selected
UserName LogicalHostId LogonStatus NullPassword CreatorName CreateTimeStamp
12 – 28
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.ProfileInfo[X] User Type
Columns Selected
[X]End
ProfileName
Supervisory
DefaultAccount
Security Administrator
DefaultDB
Administrator
SpoolSpace TempSpace ExpirePassword PasswordMinChar PassordMaxChar PasswordDigits PasswordSpecChar MaxLogonAttempts LockedUserExpire PasswordReuse CommentString CreatorName CreateTimeStamp LastAlterName LastAlterTimeStamp
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 29
Chapter 12: Data Dictionary Views View Definitions
DBC.QryLog User Type
Columns Selected
Administrator
ProcID
NOTE:
CollectTimeStamp
**This field is not used.
QueryID UserID AcctString ExpandAccString SessionID LogicalHostID RequestNum LogonDateTime AccStringTime AccStringHour AccStringDate AppID ClientID QueryBrand** ProfileID StartTime FirstStepTime FirstRespTime LastRespTime NumSteps NumStepswPar MaxStepsInPar
12 – 30
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.QryLog (continued) User Type
Columns Selected
Administrator
NumResultRows**
NOTE:
ResultRowSize**
**This field is not used.
TotalIOcount** TotalCPUTime** ErrorCode ErrorText TDQMFlag AbortFlag CacheFlag QueryText HotAmp1CPU** HotAmp2CPU** HotAmp3CPU** LowAmp1CPU** LowAmp2CPU** LowAmp3CPU** AvgAmpCPUSec** HotAmp1IO** HotAmp2IO** HotAmp3IO** LowAmp1IO** LowAmp2IO** LowAmp3IO** AvgAmpIOCnt**
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 31
Chapter 12: Data Dictionary Views View Definitions
DBC.QryLog (continued) User Type
Columns Selected
Administrator
SpoolUsage**
NOTE:
ExtraField1**
**This field is not used.
ExtraField2** ExtraField3** ExtraField4** ExtraField5**
DBC.QryLogExplain User Type
Administrator
Columns Selected
ProcID CollectTimeStamp Query ID ExpRowNo ExplainText
12 – 32
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.QryLogObjects User Type
Administrator
Columns Selected
ProcID CollectTimeStamp QueryID ObjectDatabaseName ObjectTableName ObjectColumnName ObjectID ObjectNum ObjectType FreqofUse
DBC.QryLogSQL User Type
Administrator
Columns Selected
ProcID CollectTimeStamp Query ID SqlRowNo SqlTextInfo
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 33
Chapter 12: Data Dictionary Views View Definitions
DBC.QryLogSteps User Type
Administrator NOTE: **This field is not used.
12 – 34
Columns Selected
ProdID CollectTimestamp QueryID StepLev1Num StepLev2Num StepName StepStartDate StepStopDate CPUtime ** IOcount ** RowCount ** HotAmp1CPU ** HotAmp2CPU ** HotAmp3CPU ** LowAmp1CPU ** LowAmp2CPU ** LowAmp3CPU ** AvgAmpCPUSec ** HotAmp1IO ** HotAmp2IO ** HotAmp3IO ** LowAmp1IO ** LowAmp2IO ** LowAmp3IO ** AvgAmpIOCnt ** ExtraField1 ExtraField2 ExtraField3 ExtraField4
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.QryLogSummary User Type
Administrator
Columns Selected
ProcID CollectTimeStamp SessionID QueryCount QuerySeconds LowHist HighHist
DBC.RCC_Configuration[X] User Type
Operations Control
Columns Selected
EventNum LogProcessor PhyProcessor ProcessorState RestartSeqNum Vproc
DBC.RCC_Media[X] User Type
Operations Control
Columns Selected
EventNum VolSerialId VolSequenceNum DupeDumpSet
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 35
Chapter 12: Data Dictionary Views View Definitions
DBC.RI_Child_Tables User Type
All users
Columns Selected
IndexID IndexName ChildDbID ChildTID ChildKeyFID ParentDbID ParentTID ParentKeyFID InconsistencyFlag CreatorName CreateTimeStamp
DBC.RI_Distinct_Children User Type
All users
Columns Selected
IndexID IndexName ChildDB ChildTable ParentDB ParentTable InconsistencyFlag CreatorName CreateTimeStamp
12 – 36
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.RI_Distinct_Parents User Type
All users
Columns Selected
IndexID IndexName ParentDB ParentTable ChildDB ChildTable InconsistencyFlag CreatorName CreateTimeStamp
DBC.RI_Parent_Tables User Type
All users
Columns Selected
IndexID IndexName ParentDbID ParentTID ParentKeyFID ChildDbID ChildTID ChildKeyFID InconsistencyFlag CreatorName CreateTimeStamp
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 37
Chapter 12: Data Dictionary Views View Definitions
DBC.RoleInfo[X] User Type
Columns Selected
Security Administrator
RoleName
[X]End
CreatorName CommentString CreateTimeStamp
DBC.RoleMembers[X] User Type
Columns Selected
Security Administrator
RoleName
[X]End
Grantee GranteeKind Grantor WhenGranted DefaultRole WithAdmin
12 – 38
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.SecurityDefaults User Type
Security Administrator
Columns Selected
ExpirePassword PasswordMinChar PasswordMaxChar PasswordDigits PasswordSpecChar MaxLogonAttempts LockedUserExpire PasswordReuse
DBC.SecurityLog[X] User Type
Security Administrator
Columns Selected
LogDate LogTime LogType UserName AccountName DatabaseName TableName Text
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 39
Chapter 12: Data Dictionary Views View Definitions
DBC.SessionInfo[X] User Type
Columns Selected
Administrator
UserName
Security Administrator
AccountName
Supervisory
SessionNo
[X]End
DefaultDataBase IFPNo Partition LogicalHostId HostNo CurrentCollation LogonDate LogonTime LogonSequenceNo LogonSource ExpiredPassword TwoPCMode Transaction_Mode CurrentRole LogonAcct
12 – 40
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.ShowColChecks User Type
Columns Selected
End
DatabaseName
Administrator
TableName ColumnName ColCheck CreatorName CreateTimeStamp
DBC.ShowTblChecks User Type
Columns Selected
End
DatabaseName
Administrator
TableName CheckName TblCheck CreatorName CreateTimeStamp
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 41
Chapter 12: Data Dictionary Views View Definitions
DBC.Software_Event_Log User Type
Operations Control
Columns Selected
TheDate TheTime Event_Tag Category Severity PMA Vproc Partition Task TheFunction SW_Version Line Text StackTrace Error_Data
12 – 42
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.Table_LevelConstraints User Type
All users
Columns Selected
DatabaseName TableName ConstraintName ConstraintText CreatorName CreateTimeStamp
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 43
Chapter 12: Data Dictionary Views View Definitions
DBC.Tables[X] User Type
Columns Selected
[X]End
DatabaseName
Administrator
TableName
NOTE:
Version
This field is not used.
TableKind ProtectionType JournalFlag CreatorName RequestText CommentString ParentCount ChildCount NamedTblCheckCount UnnamedTblCheckExist PrimaryKeyIndexId CreateTimeStamp LastAlterName LastAlterTimeStamp RequestTxtOverFlow AccessCount** LastAccessTimeStamp**
12 – 44
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.Tables2 User Type
Columns Selected
Administrator
TVMName
Supervisory
TVMId DatabaseId ParentCount ChildCount
DBC.TableSize[X] User Type
Columns Selected
Administrator
Vproc
[X]End
DatabaseName AccountName TableName CurrentPerm PeakPerm
DBC.TableText User Type
Columns Selected
Administrator
DatabaseName
[X]End
TableName TableKind RequestText LineNo
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 45
Chapter 12: Data Dictionary Views View Definitions
DBC.Triggers User Type
Administrator
Columns Selected
DatabaseName TableName TriggerName EnabledFlag ActionTime Event Kind OrderNumber TriggerComment RequestText CreatorName CreateTimeStamp LastAlterName LastAlterTimeStamp
12 – 46
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.UserGrantedRights User Type
End
Columns Selected
DatabaseName TableName ColumnName Grantee GrantAuthority AccessRight AllnessFlag CreatorName CreateTimeStamp
DBC.UserRights User Type
End
Columns Selected
DatabaseName TableName ColumnName AccessRight GrantAuthority GrantorName CreatorName CreateTimeStamp
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 47
Chapter 12: Data Dictionary Views View Definitions
DBC.UserRoleRights User Type
End
Columns Selected
RoleName DatabaseName TableName ColumnName AccessRight GrantorName CreateTimeStamp
12 – 48
Teradata RDBMS SQL/Data Dictionary Quick Reference
Chapter 12: Data Dictionary Views View Definitions
DBC.Users User Type
Columns Selected
Supervisory
UserName
End
CreatorName
Administrator
PasswordLastModDate PasswordLastModTime OwnerName PermSpace SpoolSpace TempSpace ProtectionType JournalFlag StartupString DefaultAccount DefaultDataBase CommentString DefaultCollation PasswordChgDate LockedDate LockedTime LockedCount TimeZoneHour TimeZoneMinute DefaultDateForm CreateTimeStamp LastAlterTime LastAlterTimeStamp DefaultCharType
Teradata RDBMS SQL/Data Dictionary Quick Reference
12 – 49
Chapter 12: Data Dictionary Views View Definitions
DBC.Users (continued) User Type
Columns Selected
RoleName ProfileName
DBC.User_Default_Journals[X] User Type
Columns Selected
[X]End
UserName
Administrator
Journal_DB JournalName
12 – 50
Teradata RDBMS SQL/Data Dictionary Quick Reference
Appendix A:
How to Read Syntax Diagrams This appendix describes the conventions that apply to reading the syntax diagrams used in this book.
Teradata RDBMS SQL/Data Dictionary Quick Reference
A–1
Appendix A: How to Read Syntax Diagrams Syntax Diagram Conventions
Syntax Diagram Conventions Notation Conventions The following table defines the notation used in this quick reference: Item
Definition / Comments
Letter
An uppercase or lowercase alphabetic character ranging from A through Z.
Number
A digit ranging from 0 through 9. Do not use commas when entering a number with more than three digits.
Word
Variables and reserved words. IF a word is shown in . . .
THEN it represents . . .
UPPERCASE LETTERS
a keyword. Syntax diagrams show all keywords in uppercase, unless operating system restrictions require them to be in lowercase. If a keyword is shown in uppercase, you may enter it in uppercase or mixed case.
lowercase italic letters
a variable such as a column or table name. You must substitute a proper value.
lowercase bold letters
A–2
a variable that is defined immediately following the diagram that contains it.
Teradata RDBMS SQL/Data Dictionary Quick Reference
Appendix A: How to Read Syntax Diagrams Syntax Diagram Conventions Item
Definition / Comments IF a word is shown in . . .
THEN it represents . . .
lowercase letters
a keyword that you must enter in lowercase, such as a UNIX command.
UNDERLINED LETTERS
the default value. This applies both to uppercase and to lowercase words.
Spaces
Use one space between items, such as keywords or variables.
Punctuation
Enter all punctuation exactly as it appears in the diagram.
Paths The main path along the syntax diagram begins at the left, and proceeds, left to right, to the vertical bar, which marks the end of the diagram. Paths that do not have an arrow or a vertical bar only show portions of the syntax. The only part of a path that reads from right to left is a loop. Paths that are too long for one line use continuation links. Continuation links are small circles with letters indicating the beginning and end of a link: A
A
FE0CA002
Teradata RDBMS SQL/Data Dictionary Quick Reference
A–3
Appendix A: How to Read Syntax Diagrams Syntax Diagram Conventions
When you see a circled letter in a syntax diagram, go to the corresponding circled letter and continue.
Required Items Required items appear on the main path: SHOW
FE0CA003
If you can choose from more than one item, the choices appear vertically, in a stack. The first item appears on the main path: SHOW
CONTROLS VERSIONS FE0CA005
Optional Items Optional items appear below the main path: SHOW CONTROLS
FE0CA004
If choosing one of the items is optional, all the choices appear below the main path: SHOW CONTROLS VERSIONS FE0CA006
You can choose one of the options, or you can disregard all of the options.
A–4
Teradata RDBMS SQL/Data Dictionary Quick Reference
Appendix A: How to Read Syntax Diagrams Syntax Diagram Conventions
Abbreviations If a keyword or a reserved word has a valid abbreviation, the unabbreviated form always appears on the main path. The shortest valid abbreviation appears beneath. SHOW
CONTROLS CONTROL FE0CA042
In the above syntax, the following formats are valid: • •
SHOW CONTROL SHOW CONTROLS
Loops A loop is an entry or a group of entries that you can repeat one or more times. Syntax diagrams show loops as a return path above the main path, over the item or items that you can repeat. , , (
3 4
cname
) JC01B012
The following rules apply to loops: IF...
THEN...
there is a maximum number of entries allowed
the number appears in a circle on the return path.
there is a minimum number of entries required
In the example, you may enter cname a maximum of 4 times. the number appears in a square on the return path. In the example, you must enter at least 3 groups of column names.
Teradata RDBMS SQL/Data Dictionary Quick Reference
A–5
Appendix A: How to Read Syntax Diagrams Syntax Diagram Conventions IF...
THEN...
a separator character is required between entries
the character appears on the return path. If the diagram does not show a separator character, use one blank space. In the example, the separator character is a comma.
a delimiter character is required around entries
the beginning and end characters appear outside the return path. Generally, a space is not needed between delimiter characters and entries. In the example, the delimiter characters are the left and right parentheses.
Excerpts Sometimes a piece of a syntax phrase is too large to fit into the diagram. Such a phrase is indicated by a break in the path, marked by | terminators on either side of the break. A name for the excerpted piece appears between the break marks in boldface type. The named phrase appears immediately after the complete diagram, as illustrated by the following example. LOCKING
excerpt
A
A HAVING
con excerpt
where_cond , cname , col_pos JC01A014
A–6
Teradata RDBMS SQL/Data Dictionary Quick Reference
Appendix B:
Restricted Words for V2R5.0 Release V2R5.0 restricts the use of certain terminology in SQL queries and in other user application programs that interface with the Teradata RDBMS. Certain words cannot be used as object names, such as database, table, column, index, or stored procedure names, because Teradata RDBMS already uses the words and might misinterpret them. Other words are permitted as object names, but discouraged because of possible confusion that might result.
Reserved and Keywords for V2R5.0 For a complete list of Teradata RDBMS V2R5.0 reserved words, non-reserved words, words reserved for future use, and SQL-99 reserved and non-reserved keywords, see Appendix A: “Restricted Words for V2R5.0” in Teradata RDBMS Release Summary.
Reserved Words Script Before upgrading from your current release of Teradata RDBMS to Release V2R5.0, run: V2R5.0 Reserved Words Script
This script reports the names of existing data objects that conflict with Teradata RDBMS reserved words, including those newly created for the current release. Customers are
Teradata RDBMS SQL/Data Dictionary Quick Reference
B–1
Appendix B: Restricted Words for V2R5.0
advised to either rename or use double quotes around any conflicting object names. Notes: •
This script does not check for table name aliases or embedded SQL statements. The script only checks for Teradata RDBMS reserved keywords and future reserved words. You must search manually for SQL-99 keywords and Teradata nonreserved keywords. For an explanation of the various classes of restricted words, see Appendix A: “Restricted Words for V2R5.0” in Teradata RDBMS Release Summary.
•
Running the Script To get the latest list of Reserved Words and Keywords, and the Reserved Words Script to check out your system, follow these steps: Step
B–2
Action
1
Go to http://www.info.ncr.com
2
Click Teradata Data Warehousing >Teradata Database >V2R5.0.0.
3
Click V2R5.0 Reserved Words Script (B035-1952122K). The script opens in another browser window.
Teradata RDBMS SQL/Data Dictionary Quick Reference
Appendix B: Restricted Words for V2R5.0
Step
4
Action
Copy and paste the script text into your own ASCII Text editor, and save this file on your local disk drive as a .bteq file. Note: Be sure to use an ASCII Text editor that does not add any control characters or extra carriage returns. Wordpad does not work for this purpose. Notepad and Editpad are good editors. If you use Notepad, be sure to keep the extension of the file as .bteq and not as a .txt file.
5
Run the file on your system as a BTEQ script.
Teradata RDBMS SQL/Data Dictionary Quick Reference
B–3
Appendix B: Restricted Words for V2R5.0
B–4
Teradata RDBMS SQL/Data Dictionary Quick Reference