15.10 - Overview of Numeric Literals - Teradata Database

Teradata Database SQL Data Types and Literals

Teradata Database
Programming Reference

A numeric literal is a string of 1 to 40 characters selected from the following:

  • plus sign
  • minus sign
  • digits 0 through 9
  • decimal point
  • Numeric literals are also referred to as numeric constants.

    Note: Teradata Database also supports a hexadecimal form of numeric literals to represent integer values. For details, see “Hexadecimal Integer Literals” on page 41.

    There are three kinds of numeric literals:

  • Integers (see “Integer Literals” and “Hexadecimal Integer Literals”)
  • Decimals (see “Decimal Literals”)
  • Floating point numbers (see “Floating Point Literals”)
  • The following are examples of valid numeric literals.
























    The following are examples of nonvalid numeric literals.


    This literal is not valid …

    Because it contains …


    more than 38 digits.


    a dollar sign and a comma.


    four digits following the E.

    For the rules on what constitutes valid numeric literals, see the following sections:

  • “Integer Literals” on page 39
  • “Decimal Literals” on page 43
  • “Floating Point Literals” on page 45
  • The data type of a numeric literal is determined by the range of the literal value. The type used is the smallest that can contain the value.

    For example, the data type of the numeric literal 127 is BYTEINT because it is the smallest type that can fit the value 127.

    For decimal literals, the total number of digits determine the precision and the number of digits to the right of the decimal point determine the scale.


    FOR details on …

    SEE …

    the range of values of integer literals

    “Integer Literal Data Types” on page 39.

    determining the scale and precision of a decimal literal

    “Scale and Precision” on page 43.

    Depending on the kind of operation performed or the type of column in which a value is to be stored, SQL may convert numeric literal constants from one numeric data type to another.

    If a literal is outside the range for its required type, an error is reported during conversion.

    For more information on numeric to numeric data type conversions, see SQL Functions, Operators, Expressions, and Predicates.

    Character data can contain a string that is intended to be interpreted as a numeric value (for example, '15'). In such cases, Teradata Database attempts to convert the string to a numeric value whenever the context makes such a conversion necessary. If the character string does not represent a valid numeric value, an error is reported.

    When data in a character column must be compared with data in a numeric column, the character data and the numeric data are converted to FLOAT before the comparison is made. Note that this can result in repeated conversions during data access.

    If numeric data is defined and stored as a character string in a character column, and a SELECT operation uses a full table scan to compare the character column with a numeric literal, then the character column is converted to numeric in every row of the table.

    For more information on character to numeric data type conversions, see SQL Functions, Operators, Expressions, and Predicates.