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

SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
2-196
Considerations for UNION
Considerations for UNION
Suppose that the contributing SELECT statements are named SELECT1 and
SELECT2, the contributing tables resulting from the SELECT statements are named
TABLE1 and TABLE2, and the table resulting from the UNION operation is named
RESULT.
Characteristics of the UNION Columns
For columns in TABLE1 and TABLE2 that contribute to the RESULT table:
If both columns contain character strings, the corresponding column in RESULT
contains a character string whose length is equal to the greater of the two
contributing columns.
If both columns contain variable-length character strings, RESULT contains a
variable-length character string whose length is equal to the greater of the two
contributing columns.
If both columns are of exact numeric data types, RESULT contains an exact
numeric value whose precision and scale are equal to the greater of the two
contributing columns.
If both columns are of approximate numeric data types, RESULT contains an
approximate numeric value whose precision is equal to the greater of the two
contributing columns.
If both columns are of datetime data type (DATE, TIME, or TIMESTAMP), the
corresponding column in RESULT has the same data type.
If both columns are INTERVAL data type and both columns are either year-month
or day-time, RESULT contains an INTERVAL value whose range of fields is the
most significant start field to the least significant end field of the INTERVAL fields in
the contributing columns. (The year-month fields are YEAR and MONTH. The
day-time fields are DAY, HOUR, MINUTE, and SECOND.)
For example, suppose that the column in TABLE1 has the data type INTERVAL
HOUR TO MINUTE, and the column in TABLE2 has the data type INTERVAL DAY
TO HOUR. The data type of the column resulting from the union operation is
INTERVAL DAY TO MINUTE.
If both columns are described with NOT NULL, the corresponding column of
RESULT cannot be null. Otherwise, the column can be null.