Data Type Details
Numeric data types
Exasol supports approximate and exact numerical data types. The difference when using the approximate data types arises from the possible rounding differences, which can occur due to the type of storage and the way computations are performed. Information losses of this nature do not occur when using exact numeric types because of storage type.
Data type | Range (min, max) | Precision | Note |
---|---|---|---|
Exact numeric type | |||
|
Precision, scale: (p,s) |
1 ≤
0 ≤
|
|
Approximate numeric type | |||
|
~15 digits |
About 15 digits can be stored, independent of the scale. The special element The element |
String data types
Exasol supports two SQL standard types for characters: CHAR
and VARCHAR
.
CHAR(n)
has a fixed and pre-defined length n
. If you insert a value that is shorter than n
, space characters are automatically added to fill the remaining space (padding). The maximum allowed length is 2,000 characters.
VARCHAR(n)
can contain a string of the length n
or smaller. The string is stored in its actual length without padding. The maximum allowed length is 2,000,000 characters.
You can use ASCII or UTF-8 (Unicode) to define the character set in CHAR
and VARCHAR
. If no character set is defined, UTF-8 is used by default.
Data type | Character set | Note |
---|---|---|
|
ASCII, UTF-8 |
1 ≤ |
|
ASCII, UTF-8 |
1 ≤ |
An empty string is evaluated as NULL
.
To display the character set of a certain column you can use the DESC[RIBE] command.
stringtype_definition::=
Date and time data types
Exasol supports the DATE
and TIMESTAMP(p)
data types from the SQL standard. Additionally, the data type TIMESTAMP(p) WITH LOCAL TIME ZONE
can be used to handle timestamps in the session time zone. For more information, see ALTER SESSION and SESSIONTIMEZONE.
Data type | Range | Note |
---|---|---|
|
0001-01-01 to 9999-12-31 |
|
|
|
Timestamp without time zone.
0 ≤ The fractional seconds precision |
|
|
Timestamp considering the session time zone. If the session time zone is not set to UTC, the usable range is slightly smaller because all timestamps must be within this range in both the session time zone and UTC.
0 ≤ The fractional seconds precision |
For the timestamp data types, p
is the fractional seconds precision which defines the number of fractional digits that can be stored for the second of the timestamp. For example, TIMESTAMP(4)
can be used to store the timestamp 2024-01-31 00:00:00.1234
. Commonly used fractional seconds precisions are:
0
= whole seconds
3
= millisecond precision
6
= microsecond precision
9
= nanosecond precision
TIMESTAMP(p) WITH LOCAL TIME ZONE usage notes
In TIMESTAMP(p) WITH LOCAL TIME ZONE
columns the timestamps are internally normalized to UTC, while the input and output values are interpreted in the session time zone. Hence, users in different time zones can easily insert and display data without worrying about internal storage. However, you should be aware that executing the same SQL statements in sessions with different time zones can lead to different results.
When casting between the data types TIMESTAMP(p) WITH LOCAL TIME ZONE
and TIMESTAMP(p)
, the session time zone is evaluated and the TIMESTAMP(p) WITH LOCAL TIME ZONE
is transformed into a TIMESTAMP(p)
data type. This is the same as displaying a TIMESTAMP(p) WITH LOCAL TIME ZONE
value. For example, in your database client, the internal UTC normalized value is also converted to TIMESTAMP(p)
data type, considering the session time zone.
TIME_ZONE_BEHAVIOR
While TIMESTAMP(p)
is a simple structure consisting of a year, month, day, hour, minute, and second, data of type TIMESTAMP(p) WITH LOCAL TIME ZONE
represents a specific moment on the time axis. Internally, the data is normalized to UTC because within certain time zones there may be time shifts and ambiguous periods, for example, when switching to/from daylight saving time. If such problematic values are inserted within the local session time zone, the session value TIME_ZONE_BEHAVIOR
defines how they are treated. The value is set using ALTER SESSION and consists of a string defining the two parameters INVALID
and AMBIGUOUS
, separated by spaces.
When time is set forward in a time zone, there will be a gap. To define how a timestamp located in the gap should be treated, set one of the following values for INVALID
:
SHIFT
- Corrects the value by adding the daylight saving time offset (typically one hour)
ADJUST
- Rounds the value to the first valid value after the time shift
NULLIFY
- Sets the value to NULL
REJECT
- Throws an exception
When time is set back in a time zone, timestamps may become ambiguous. To define how an ambiguous timestamp should be treated, set one of the following values for AMBIGUOUS
:
ST
- Interprets the value in Standard Time (ST)
DST
- Interprets the values in Daylight Saving Time (DST)
NULLIFY
- Sets the value to NULL
REJECT
- Throws an exception
Example:
Literals
There are no special literals for the data type TIMESTAMP(p) WITH LOCAL TIME ZONE
. The literal for data type TIMESTAMP(p)
is considered, and the session time zone defines the corresponding moment on the time axis. For details about the arithmetic on datetime
values and the datetime
functions, see the Scalar Functions and Operators. For more information, see Literals.
Timestamp in statistical system tables
The timestamp values logged in statistical system tables are rendered in the database time zone (DBTIMEZONE). This is particularly relevant if you want to use the different functions for the current timestamp:
Function |
Description |
---|---|
|
Returns the current timestamp with fractional seconds precision |
|
Returns the current timestamp with fractional seconds precision |
|
Equivalent to |
|
Equivalent to |
A list of supported time zones can be found in the system table EXA_TIME_ZONES.
Interval data types
Using the interval data types you can define time periods that are especially useful for datetime arithmetic.
Data type | Range | Note |
---|---|---|
|
For example: |
1 ≤ The leading field precision |
|
For example: |
1 ≤ The leading field precision
0 ≤ The accuracy is limited to milliseconds. The fractional seconds precision |
Boolean data type
The SQL standard data type BOOLEAN
is directly supported in Exasol.
Data type | Range | Note |
---|---|---|
|
TRUE , FALSE , NULL (unknown) |
Integers or strings (case-insensitive) can be interpreted as well as boolean literals:
|
Geospatial data type
The geospatial data type can store various geometry objects. For more information, see Geospatial Data.
Data type | Possible elements | Note |
---|---|---|
|
POINT , LINESTRING , POLYGON , MULTIPOINT , MULTILINESTRING , MULTIPOLYGON , GEOMETRYCOLLECTION |
|
HASHTYPE data type
The HASHTYPE data type can be used to store hash values such as MD5 hashes or universally unique identifiers (UUID).
There is no special literal for the HASHTYPE data type. Values are defined as strings and must be delimited with single quotes. Dashes (-) in the input hash string will be ignored. Curly brackets surrounding the input hash string are allowed.
Data type | Note |
---|---|
or
|
1 ≤
8 ≤ Default = |
Input formats
The following formats are accepted as input for the HASHTYPE
data type:
-
Hexadecimal string
-
UUID
-
base64 encoded ASCII string, for example:
chatkYY/Tsai+DDVIukNnw
-
base64url encoded ASCII string, for example:
chatkYY_Tsai-DDVIukNnw
UUID is only supported for HASHTYPE(16 BYTE).
Examples of valid input strings for HASHTYPE(16 BYTE):
create table t1 (my_hash HASHTYPE);
insert into t1 values ('550e8400-e29b-11d4-a716-446655440000');
insert into t1 values ('{550e8400-e29b-11d4-a716-446655440000}');
insert into t1 values ('550e8400e29b11d4a716446655440000');
insert into t1 values ('550e-8400-e29b-11d4-a716-4466-5544-0000');
insert into t1 values ('VQ6EAOKbEdSnFkRmVUQAAA');
Output
The parameter HASHTYPE_FORMAT defines the output format of data that is stored as HASHTYPE. The default output of hex strings and UUID is a hex string. The format can be changed to UUID
Conversion from hash data type string to base64 and base64url encoded ASCII string is done without a padding character. Conversion from base64 and base64url encoded ASCII string to hash data type string supports both padded and unpadded input. The padding character = is optional. The implementation follows the RFC-4648 standard. For more information, see RFC-4648.