ALLBASE/SQL Reference Manual (36216-90216)

210 Chapter7
Data Types
Type Specifications
Your choice of data types can affect the following:
How values are used in expressions. Some operations can be performed only with data
of a certain type. For example, arithmetic operations are limited to numeric and
date/time data types, such as INTEGER, SMALLINT, FLOAT, DECIMAL, DATE,
TIME, DATETIME, or INTERVAL. Pattern matching with the LIKE predicate can be
performed only with string data, that is, data of types CHAR or VARCHAR.
The result of operations combining data of different types. When comparisons and
expressions combining data of different but compatible types are evaluated,
ALLBASE/SQL performs type conversion, as described later in this chapter.
How values are transferred programmatically. When data is transferred between
ALLBASE/SQL and an application program in host variables, ALLBASE/SQL uses the
data type equivalencies described in the ALLBASE/SQL application programming
guides.
Table 7-2. contains the storage requirements of the various data types.
Table 7-2. Data Type Storage Requirements
Type Storage Required
CHAR (n) n bytes (where n must be an integer from 1 to 3996)
VARCHAR (n) n bytes (where n must be an integer from 1 to 3996)
DECIMAL (p[,s]) 4 bytes (where p <= 7) or 8 bytes (where 7<p<=15)or12bytes (where 15
< p <= 23) or 16 bytes (where p > 23)
FLOAT 8 bytes
REAL 4 bytes
INTEGER 4 bytes. Integer values less than -2147483648 (-2**31) or larger than
2147483647 (2**31 - 1) up to 15 digits long are stored as decimals with a
precision of 15 and a scale of 0, i.e., equivalent to DECIMAL (15,0)
SMALLINT 2 bytes
DATE 16 bytes
TIME 16 bytes
DATETIME 16 bytes
INTERVAL 16 bytes
BINARY (n) n bytes (where n must be an integer from 1 to 3996)
VARBINARY (n) n bytes (where n must be an integer from 1 to 3996)
LONG BINARY (n)
n bytes (where n must be an integer from 1 to 2
31
- 1)
LONG
VARBINARY (n)
n bytes (where n must be an integer from 1 to 2
31
- 1)