15.00 - Arithmetic Operators - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

prodname
Teradata Database
vrm_release
15.00
category
Programming Reference
featnum
B035-1145-015K

Arithmetic Operators

Teradata SQL supports the following arithmetic operators.

 

Operator

Function

**

Exponentiate

This is a Teradata extension to the ANSI SQL:2011 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:2011 standard.

+

Add

-

Subtract

+

Unary plus (positive value)

-

Unary minus (negative value)

ANSI Compliance

Except for MOD and **, the arithmetic operators are ANSI SQL:2011 compliant.

Arithmetic Operators and LOBs

Arithmetic operators do not support BLOB or CLOB types.

Arithmetic Operators and DateTime and Interval Data Types

For details on the arithmetic operators permitted for DateTime and Interval data types, see “Arithmetic Operators and ANSI DateTime and Interval Data Types” on page 842.

Arithmetic Operators and Period Data Types

For details on the arithmetic operators permitted for Period data types, see “Arithmetic Operators” on page 1057.

Arithmetic Operators and UDTs

By default, Teradata Database performs implicit type conversion on a UDT argument that has an implicit cast that casts between the UDT and a predefined numeric data type such as FLOAT or INTEGER.

To define an implicit cast for a UDT, use the CREATE CAST statement and specify the AS ASSIGNMENT clause. For more information on CREATE CAST, see SQL Data Definition Language.

Implicit type conversion of UDTs for system operators and functions, including arithmetic operators, is a Teradata extension to the ANSI SQL standard. To disable this extension, set the DisableUDTImplCastForSysFuncOp field of the DBS Control Record to TRUE. For details, see Utilities: Volume 1 (A-K).

For more information on implicit type conversion of UDTs, see “Implicit Type Conversions” on page 583.