SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Language Elements
HP NonStop SQL/MX Reference Manual540440-003
6-16
Data Types
Data Types
SQL/MX data types are either character, datetime, interval, or numeric (exact or
approximate):
Each column in a table is associated with a data type. You can use the CAST
expression to convert data to the data type that you specify. For more information, see
CAST Expression on page 9-20.
Comparable and Compatible Data Types
Two data types are comparable if a value of one data type can be compared to a value
of the other data type.
Two data types are compatible if a value of one data type can be assigned to a column
of the other data type, and if columns of the two data types can be combined using
arithmetic operations. Compatible data types are also comparable.
Assignment and comparison are the basic operations of NonStop SQL/MX.
Assignment operations are performed during the execution of INSERT and UPDATE
statements. Comparison operations are performed during the execution of statements
that include predicates, aggregate (or set) functions, and GROUP BY, HAVING, and
ORDER BY clauses.
The basic rule for both assignment and comparison is that the operands have
compatible data types. For assignment operations, a further restriction is that null
cannot be assigned to a column that has been defined as NOT NULL. Data types with
different character sets cannot be compared.
Character Data Types
Values of fixed and variable length character data types of the same character set are
all character strings and are all mutually comparable and mutually assignable.
When two strings are compared, the comparison is made with a temporary copy of the
shorter string that has been padded on the right with blanks to have the same length
as the longer string.
Character String Data Types
on page 6-19
Fixed-length and variable-length character data types.
Datetime Data Types
on
page 6-23
DATE, TIME, and TIMESTAMP data types.
Interval Data Types
on
page 6-28
Year-month intervals (years and months) and day-time
intervals (days, hours, minutes, seconds, and fractions of a
second).
Numeric Data Types
on
page 6-31
Exact and approximate numeric data types.