Usage Notes

Teradata Vantage™ Data Types and Literals

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1143-162K

The ANSI SQL:2011 compliant form can be used to convert data types in either ANSI-compliant SQL statements or Teradata SQL statements.

The Teradata extended syntax is more general. It allows a type declaration or data attributes or both.

Avoid using the extended form of CAST for any application intended to be ANSI-compliant and portable.

CAST functions identically in both ANSI and Teradata modes.

When converting DateTime data types, you can use the AT clause to specify the time zone used for the CAST. You can specify the source time zone, a specific time zone displacement, or the current session time zone. For more information, see the section on converting the specific data type, for example, TIMESTAMP-to-DATE Conversion.

CAST does not convert the following data type pairs:
  • Numeric to character, if the server character set is GRAPHIC.
  • Character expressions having different server character sets.

    To make such a conversion, use the TRANSLATE function. For more information, see "TRANSLATE" in Teradata Vantage™ SQL Functions, Expressions, and Predicates, B035-1145.

  • Byte (BYTE, VARBYTE, and BLOB) to any data type other than UDT or byte, and data types other than byte or UDT to byte.
  • CLOB to any data type other than UDT or character, and data types other than character or UDT to CLOB.

For information on casting to and from geospatial types, see Teradata Vantage™ Geospatial Data Types , B035-1181 .

Data type conversions involving UDTs require appropriate cast definitions for the UDTs. To define a cast for a UDT, use the CREATE CAST statement.