6.2.1 List of data types
The following table lists the data types supported by HADB.
|
No. |
Category |
Data type |
Data type code#1 |
Length of data storage (in bytes) |
Data format |
||
|---|---|---|---|---|---|---|---|
|
Decimal |
Hex |
||||||
|
1 |
Numeric data |
Integer data |
BIGINT |
241 |
F1 |
8 |
Integer (8-byte) |
|
2 |
INTEGER#3 |
245 |
F5 |
4 |
Integer (4-byte) |
||
|
3 |
SMALLINT#3 |
247 |
F7 |
2 |
Integer (2-byte) |
||
|
4 |
Fixed-point number data |
DECIMAL(m,n) |
229 |
E5 |
|
Fixed-point number |
|
|
5 |
NUMERIC(m,n) |
||||||
|
6 |
Floating-point numeric data |
DOUBLE PRECISION |
225 |
E1 |
8 |
Double-precision floating-point number (8 bytes) |
|
|
7 |
FLOAT |
||||||
|
8 |
REAL |
227 |
E3 |
4 |
Single-precision floating-point number (4 bytes) |
||
|
9 |
Character string data |
CHARACTER(n) |
197 |
C5 |
n |
Fixed-length character string |
|
|
10 |
VARCHAR(n) |
193 |
C1 |
n + 2 |
Variable-length character string |
||
|
11 |
STRING |
||||||
|
12 |
Datetime data |
Date data |
DATE |
113 |
71 |
4 |
Data type for dates, with fields for the year, month, and day |
|
13 |
Time data |
TIME(p) |
121 |
79 |
3 + ↑p ÷ 2↑ |
Data type for time, with fields for the hour, minute, and seconds |
|
|
14 |
Time stamp data (TIMESTAMP) |
TIMESTAMP(p) WITHOUT TIME ZONE |
125 |
7D |
7 + ↑p ÷ 2↑ |
|
|
|
15 |
TIMESTAMP(p) WITH TIME ZONE |
127 |
7F |
||||
|
16 |
Binary data |
BINARY(n) |
149 |
95 |
n |
Fixed-length binary data |
|
|
17 |
VARBINARY(n) |
145 |
91 |
n + +2 |
Variable-length binary data |
||
|
18 |
Logical data |
BOOLEAN |
33 |
21 |
1 |
Data type that represents a logical value that can be true, false, or unknown |
|
|
19 |
UUID data |
UUID |
155 |
9B |
16 |
Binary data with a fixed length of 16 bytes that represents UUID |
|
|
20 |
Array data |
ARRAY |
None |
None |
Follows the element data type |
One-dimensional array data with an ordered series of data as elements |
|
|
21 |
Structure data |
STRUCT |
139 |
8B |
According to the field data type |
Data type consisting of data of multiple data types |
|
|
22 |
Row data |
ROW |
69 |
45 |
Row length#2 |
Data type used for row interface |
|
- #1
-
The code that represents the data type of the retrieval results column.
When using a CLI function, the data type code is stored in the structure a_rdb_SQLDataType_t.
- #2
-
The row length is the sum of the data storage size of each column.
- #3
-
If the integer data type format is in a legacy format, the data type code, data storage length, and data format are as shown in the following table.
Data type
Data type code
Length of data storage
Data format
Decimal
Hex
INTEGER
241
F1
8
Integer (8-byte)
SMALLINT
245
F5
4
Integer (4-byte)
- Organization of this subsection
(1) Numeric data
This section describes numeric data.
(a) Integer data
The following table shows the integer data (BIGINT, INTEGER, and SMALLINT) supported by HADB.
|
Integer data |
Description |
|---|---|
|
BIGINT#1 |
|
|
INTEGER |
|
|
SMALLINT |
|
- #1
-
If the integer data type format is a legacy format, when BIGINT type is specified as the data type, HADB assumes that the INTEGER type is specified.
- #2
-
If the integer data type format is in a legacy format, the INTEGER type is an 8-byte signed integer. The data format is 8-byte binary format and can handle integers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
If it is in a legacy format, the INTEGER and BIGINT type is the same data format (8-byte signed integer). Therefore, the database capacity will be the same whether the INTEGER or BIGINT type is used.
- #3
-
If the integer data type format is in a legacy format, the SMALLINT type is an 8-byte signed integer. The data format is 4-byte binary format and can handle integers from -2,147,483,648 to 2,147,483,647.
- Integer data type format
-
In HADB, there are two integer data type formats, the default format and the legacy format, as shown in the following table, and either one can be selected.
Table 6‒7: Integer data type format Integer data
Integer data type format
Default format
Legacy format
BIGINT
8-byte signed integer
INTEGER
4-byte signed integer
8-byte signed integer
SMALLINT
2-byte signed integer
4-byte signed integer
As shown in the table above, the data formats of the INTEGER and SMALLINT types differ between the default and legacy formats. Usually the default format is applied. If you want to apply the legacy format, specify LEGACY in the adb_init_integer_format operand in the adbinit command executed at the time of initial database setup.
- Important
-
The integer data type format can only be selected when the adbinit command is executed. After that, the integer data type format cannot be changed. If you want to change the format, the database must be initialized again.
- Note
-
-
The integer data type format is inherited even after the HADB server gets a version upgrade.
-
The legacy format is the same as the data format prior to HADB 06-00. If the HADB server gets a version upgrade from a version prior to 06-00, the integer data type format is inherited in its legacy format.
-
When there is a specification difference between the default format and the legacy format, the legacy format specification is described with the notation "integer data type format in legacy format".
-
(b) Fixed-point number data
This section describes the fixed-point number data (DECIMAL, NUMERIC) supported by HADB.
- ■ DECIMAL, NUMERIC
-
-
This data type handles fixed-point numbers.
-
The following shows the format to use when specifying this data type:
-
In the case of DECIMAL
DEC[(m[,n])] or DECIMAL[(m[,n])]
-
In the case of NUMERIC
NUMERIC[(m[,n])]
- Important
-
If type NUMERIC is specified as the data type, HADB assumes that type DECIMAL is specified for the data type.
-
-
The precision (overall number of digits) is specified in m, and the scaling (number of digits in the fractional part) is specified in n.
-
M and n are positive integers, with 1≤m≤38, 0≤n≤38, and n≤m.
-
If m is omitted, 38 is assumed, and if n is omitted, 0 is assumed.
-
The data is stored internally in binary format. The binary value that is stored depends on the scaling.
-
Negative values are represented in two's complement format.
-
The data is stored as integer data of 2 to 16 bytes, depending on the precision, as illustrated in the following figure:
Figure 6‒5: Data format of DECIMAL -
Literals are written in the form 123.4, 12.345, and so on. For details about literals, see 6.3 Literals.
-
(c) Floating-point numeric data
This section describes the floating-point numeric data (DOUBLE PRECISION, FLOAT, and REAL) supported by HADB.
- ■ DOUBLE PRECISION, FLOAT
-
-
This data type handles double-precision floating-point numbers. The ranges of values covered include approximately -1.7 × 10308 to -2.3 × 10-308, 0, and approximately 2.3 × 10-308 to 1.7 × 10308.
The exact range of values depends on the hardware representation.
-
The following shows the format to use when specifying this data type:
-
In case of DOUBLE PRECISION
DOUBLE or DOUBLE PRECISION
-
In the case of FLOAT
FLOAT
- Important
-
If a FLOAT type is specified as the data type, HADB assumes that a DOUBLE PRECISION type is specified.
-
-
The data is an 8-byte floating-point numeric data.
-
In the case of literals such as 1.0e2 or -3.4E-1, the mantissa is represented by an integer or decimal literal, and the exponent is stored as an integer of no more than 3 digits. For details about literals, see 6.3 Literals.
-
This data type cannot handle NaN (not a number) and infinite values.
-
-0 is converted to +0.
-
Subnormal numbers are converted to +0.
-
When floating-point numeric data is rounded, it is rounded to the nearest even number.
-
- ■REAL
-
-
This data type handles single-precision floating-point numbers. The ranges of values covered include approximately 3.4×1038 to -1.2×10-38, 0, and approximately 1.2×10-38 to 3.4×1038.
The exact range of values depends on the hardware representation.
-
The following shows the format to use when specifying this data type:
REAL
-
The data is an 4-byte floating-point numeric data.
-
In the case of literals such as 1.0e2 or -3.4E-1, the mantissa is represented by an integer or decimal literal, and the exponent is stored as an integer of no more than 2 digits. For details about literals, see 6.3 Literals.
-
This data type cannot handle NaN (not a number) and infinite values.
-
-0 is converted to +0.
-
Subnormal numbers are converted to +0.
-
When floating-point numeric data is rounded, it is rounded to the nearest even number.
-
Using the REAL type requires less space in the database than using the DOUBLE PRECISION or FLOAT types.
-
(2) Character string data
- ■ CHARACTER
-
-
This data type handles fixed-length character strings.
-
The following shows the format to use when specifying this data type:
CHAR, CHAR(n), CHARACTER, or CHARACTER(n)
-
The length of the character string (number of bytes) is specified in n, where n is an integer in the range 1 to 32,000. If n is omitted, 1 is assumed.
-
Literals are written in the form 'char'. For details about literals, see 6.3 Literals.
-
Both half-width and full-width characters can be handled.
-
When you perform comparisons on character string data, the ordering of the character encoding determines the ordering of the data being compared.
-
- ■VARCHAR, STRING
-
-
This data type handles variable-length character strings.
-
The following shows the format to use when specifying this data type:
-
In the case of VARCHAR
VARCHAR(n)
-
In the case of STRING
STRING
- Important
-
-
STRING type column can only be defined in a foreign table. You cannot define a STRING type column in a base table.
-
If STRING type is specified as the data type, HADB assumes that VARCHAR(32000000) is specified for the data type.
-
-
-
In the preceding format, n specifies (in bytes) the maximum length of each character string. The value of n must be an integer in the range from 1 to 64,000. n cannot be omitted.
-
The data format of the VARCHAR type is shown in the following figure.
Figure 6‒6: Data format of VARCHAR type The character string data length (L) is represented by four bytes.
-
Both half-width and full-width characters can be handled. The length of the character string can be 0 bytes.
-
When you perform comparisons on character string data, the ordering of the character encoding determines the ordering of the data being compared.
-
You cannot specify VARCHAR-type data whose length exceeds 32,000 bytes in the following locations:
-
Data type specified in the column definition in an ALTER TABLE statement
-
Data type specified in the column definition in a CREATE FOREIGN TABLE statement
-
Data type specified in the column definition in a CREATE TABLE statement
-
Data type specified in a table function column list
-
Post-conversion data type specified in the scalar function CAST
-
Post-conversion data type specified in the scalar function CONVERT
-
-
STRING type cannot be specified in the following locations.
-
Data type specified in the column definition in an ALTER TABLE statement
-
Data type specified in the column definition in a CREATE TABLE statement
-
Data type specified in a table function column list
-
-
(3) Datetime data
- ■ DATE
-
-
This is the data type for dates, with fields for the year, month, and day.
-
The following shows the format to use when specifying this data type:
DATE
-
It can handle dates with a range of values from January 1, 0001 to December 31, 9999.
-
The data length is 4 bytes. The data that is entered must be this length.
-
The data format of the DATE type is shown in the following figure.
Figure 6‒7: Data format of DATE type -
Literals are written in the form DATE'2012-03-30' or DATE'2012/03/30'. For details about literals, see 6.3 Literals.
-
- ■ TIME
-
-
This is the data type for time, with fields for the hour, minute, and seconds.
-
The following shows the format to use when specifying this data type:
TIME(p) or TIME
p specifies the fractional seconds precision (the number of digits to the right of the decimal point). You can specify a value of 0, 3, 6, 9, or 12 for p.
If TIME is specified, p is assumed to be 0.
-
This format can handle times with a range of values from 0 hours, 0 minutes, and 0.000000000000 seconds to 23 hours, 59 minutes, and 59.999999999999 seconds.
-
The data length is 3 + ↑p ÷ 2↑ bytes. The data that is entered must be this length.
-
The data format of the TIME type is shown in the following figure.
Figure 6‒8: Data format of TIME type One digit is represented in 4 bits. If the fractional seconds precision is an odd number, zeros are stored in the final 4 bits.
-
Literals are written in the form TIME'11:03:58.123456'. For details about literals, see 6.3 Literals.
-
- ■ TIMESTAMP (TIMESTAMP WITHOUT TIME ZONE, TIMESTAMP WITH TIME ZONE)
-
-
This is the data type for time stamps, with fields for the year, month, day, hour, minute, and seconds.
-
There are two data types for the TIMESTAMP type:
-
TIMESTAMP WITHOUT TIME ZONE (time stamp data without time zone)
-
TIMESTAMP WITH TIME ZONE (time stamp data with time zone)
-
-
The following shows the format to use when specifying this data type:
-
For TIMESTAMP WITHOUT TIME ZONE
Specify in either of the following formats:
TIMESTAMP(p) TIMESTAMP
-
For TIMESTAMP WITH TIME ZONE
Specify in either of the following formats:
TIMESTAMP(p) WITH TIME ZONE TIMESTAMP WITH TIME ZONE
Values entered in TIMESTAMP WITH TIME ZONE (time stamp data with time zone) are converted to Coordinated Universal Time (UTC) and treated as UTC (+00:00) data.
Example: 2025-10-21 15:00+09:00 is converted to 2025-10-21 06:00+00:00.
p specifies the fractional seconds precision (the number of digits to the right of the decimal point). You can specify a value of 0, 3, 6, 9, or 12 for p.
If (p) is omitted, p is assumed to be 0.
-
-
It can handle time stamps with a range of values from January 1, 0001 0:0:0.000000000000 to December 31, 9999 23:59:59.999999999999.
-
The data length is 7 + ↑p ÷ 2↑ bytes. The data that is entered must be this length.
-
The data format of the TIMESTAMP type is shown in the following figure.
Figure 6‒9: Data format of TIMESTAMP type One digit is represented in 4 bits. If the fractional seconds precision is an odd number, zeros are stored in the final 4 bits.
- Note
-
TIMESTAMP WITH TIME ZONE (time stamp data with time zone) is converted to TIMESTAMP WITHOUT TIME ZONE (time stamp data without time zone) (converted to UTC); therefore, both time stamp data with time zone and time stamp data without time zone have the same data format.
-
Literals are written in the following format. For details about literals, see 6.3 Literals.
-
For TIMESTAMP WITHOUT TIME ZONE
TIMESTAMP'2025-07-30 11:03:58'
-
For TIMESTAMP WITH TIME ZONE
TIMESTAMP'2025-07-30 11:03:58+09:00' TIMESTAMP'2025-07-30 11:03:58Z'
-
-
(4) Binary data
- ■ BINARY
-
-
This is the data type for handling fixed-length binary data.
-
The following shows the format to use when specifying this data type:
BINARY(n), or BINARY
-
The length of the binary data (number of bytes) is specified in n. If n is omitted, 1 is assumed.
-
Literals are written in the form X'0A38ef92'. For details about literals, see 6.3 Literals.
-
The data format of the BINARY type is shown in the following figure.
Figure 6‒10: Data format of BINARY type
-
- ■ VARBINARY
-
-
This is the data type for handling variable-length binary data.
-
The following shows the format to use when specifying this data type:
VARBINARY(n)
-
In the preceding format, n specifies (in bytes) the maximum length of the binary data. The value of n must be an integer in the range from 1 to 32,000. n cannot be omitted.
-
Literals are written in the form X'0A38ef92'. For details about literals, see 6.3 Literals.
-
The length of the binary data can be 0 bytes.
-
The data format of the VARBINARY type is shown in the following figure.
Figure 6‒11: Data format of VARBINARY type The length of the binary data (L) is represented in two bytes.
-
(5) Logical data
- ■ BOOLEAN
-
-
A data type that represents a logical value that can be true, false, or unknown.
-
Unknown logical data is considered a null value.
-
The following shows the format to use when specifying this data type:
BOOLEAN
-
Data length is 1 byte. It is treated as 'T'(0x54) for true, and 'F'(0x46) for false.
-
Literals are specified as TRUE or FALSE. For details about literals, see 6.3 Literals.
-
(6) UUID data
- ■ UUID
-
-
A data type that represents UUID.
-
The following shows the format to use when specifying this data type:
UUID
-
The data is fixed-length binary data of 16 bytes.
-
A literal is described in the format UUID'd68fab5b-f44c-42ae-8b8d-8da66ab31042'. For details about literals, see 6.3 Literals.
-
The following figure shows the data format of the UUID type.
Figure 6‒12: Data format of UUID type - Explanation:
-
One digit is represented in 4 bits.
For UUID data in the format AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE, the following values are stored:
A: 0x0 to 0x9, 0xA to 0xF
B: 0x0 to 0x9, 0xA to 0xF
C: 0x0 to 0x9, 0xA to 0xF
D: 0x0 to 0x9, 0xA to 0xF
E: 0x0 to 0x9, 0xA to 0xF
-
The version of UUID handled by HADB depends on the application or system that generated the UUID data. HADB does not perform processing that is aware of the UUID version.
-
(7) Array data
- ■ ARRAY (array type)
-
-
An array type is a data type that handles one-dimensional array data consisting of an ordered sequence of data elements.
-
The following shows the format to use when specifying this data type:
element-data-type ARRAY[maximum-number-of-elements]
- element-data-type:
-
Specifies the array element data type.
Specify numeric data, character string data, datetime data, binary data, logical data, UUID data, or structure data for the element data type. The description format of element data types follows the rules for the description format of each data type.
- Important
-
Only column definitions in CREATE FOREIGN TABLE statements can specify structure data for the element data type.
- maximum-number-of-elements:
-
Specifies the maximum number of array elements.
Specify an unsigned integer literal in the range from 2 to 30,000 as the maximum number of elements.
Example:
-
If the element data type is CHAR(5) and the maximum number of elements is 20
CHAR(5) ARRAY[20]
-
If the element data type is INTEGER and the maximum number of elements is 5
INTEGER ARRAY[5]
-
Each element of array data is called an array element. Each array element is assigned an element number. An unsigned integer literal element number is assigned to each array element, with the element number of the first array element being 1, followed by 2, 3, ... in that order.
-
An array data with zero array elements is called empty array data.
-
For considerations when defining array-type columns, see Defining an array-type column [column store table] in the HADB Setup and Operation Guide.
-
When structure data is specified as nested in an element data type, structure data and array data can be repeated up to eight times.
Example: When structure data is specified eight times nested in the element data type
STRUCT {"A1" INT, "A2" STRUCT {"B1" INT, "B2" STRUCT {"C1" INT, "C2" STRUCT {"D1" INT, "D2" INT ARRAY[2] } ARRAY[3] } ARRAY[4] } ARRAY[5] } ARRAY[6]
-
(8) Structure data
- ■ STRUCT
-
-
Structure data is a data type that handles data comprised of multiple data types.
- Important
-
STRUCT type columns can only be defined in foreign tables. You cannot define a STRUCT type column in the base table.
-
The following shows the format to use when specifying this data type:
STRUCT {field-name field-data-type [,field-name field-data-type]...}- field-name
-
Specifies the name of a field in the structure data. For rules on specifying a field name, see (2) Rules for characters that can be used in names in 6.1.4 Specifying names.
- field-data-type
-
Specifies the data type of the field in the structure data. Numeric data, character string data, datetime data, binary data, logical data, UUID data, array data, or structure data can be specified for the field data type.
- Note
-
The combination of a field name and field data type is called a field.
<Specification example>
-
STRUCT type comprised of the following field names and field data types
-
A1: INTEGER
-
A2: CHAR(5)
-
A3: DATE
STRUCT {"A1" INTEGER,"A2" CHAR(5),"A3" DATE} -
-
STRUCT type comprised of the following field names and field data types
-
B1: INTEGER
-
B2: CHAR(5)
-
B3: STRUCT
A1: INTEGER
A2: CHAR(5)
A3: DATE
STRUCT {"B1" INTEGER, "B2" CHAR(5), "B3" STRUCT {"A1" INTEGER,"A2" CHAR(5),"A3" DATE}} -
-
The maximum number of fields is 1,000. When structure data is defined in structure data, the maximum total number of fields for all structure data is 1,000.
-
Field names must be unique. However, if structure data is defined within structure data, the same field name can be specified for both the structure data and its nested structure data.
-
When structure data or array data is specified as nested in a field data type, structure data and array data can be repeated up to eight times. The following is an example of specifying eight times nested structure data or array data for a field data type.
Example 1:
STRUCT {"A1" INT, "B1" STRUCT {"A2" INT, "B2" STRUCT {"A3" INT, "B3" STRUCT {"A4" INT, "B4" STRUCT {"A5" INT, "B5" STRUCT {"A6" INT, "B6" STRUCT {"A7" INT, "B7" STRUCT {"A8" INT, "B8" STRUCT {"A9" INT, "B9" INT}}}}}}}}}Example 2:
STRUCT {"A1" INT, "B1" STRUCT {"A2" INT, "B2" STRUCT {"A3" INT, "B3" STRUCT {"A4" INT, "B4" STRUCT {"A5" INT, "B5" STRUCT {"A6" INT, "B6" STRUCT {"A7" INT, "B7" STRUCT {"A8" INT, "B8" INT} ARRAY[9]}}}}}}}
-