Storing column length
The collength column value depends on the data type of the column.
Integer-based data types
Integer-based data types | Length (in bytes) |
---|---|
SMALLINT | 2 |
DATE, INTEGER, and SERIAL | 4 |
INT8 and SERIAL8 | 10 |
BIGINT and BIGSERIAL | 8 |
Varying-length character data types
For HCL OneDB™ columns
of the LVARCHAR type, collength has the value of max from
the data type declaration, or 2048
if no maximum
was specified.
- If the collength value is positive:
collength = (min_space * 256) + max_size
- If the collength value is negative:
collength + 65536 = (min_space * 256) + max_size
Time data types
As noted
previously, DATE columns have a value of 4
in the collength column.
(length * 256) + (first_qualifier * 16) + last_qualifier
Field qualifier | Value | Field qualifier | Value |
---|---|---|---|
YEAR | 0 | FRACTION(1) | 11 |
MONTH | 2 | FRACTION(2) | 12 |
DAY | 4 | FRACTION(3) | 13 |
HOUR | 6 | FRACTION(4) | 14 |
MINUTE | 8 | FRACTION(5) | 15 |
SECOND | 10 |
For example, if a DATETIME YEAR TO MINUTE column has
a length of 12
(such as YYYY:DD:MO:HH:MI),
a first_qualifier value of 0
(for YEAR), and
a last_qualifier value of 8
(for MINUTE),
then the collength value is 3080
(from (256
* 12) + (0 * 16) + 8
).
Fixed-point data types
(precision * 256) + scale
Simple-large-object data types
If the data type of the column is BYTE or TEXT, collength holds the length of the descriptor.