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
data types from the SQL standard. Additionally, the data type TIMESTAMP 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. The accuracy is limited to milliseconds. |
|
|
Timestamp considering the session time zone. The accuracy is limited to milliseconds. |
TIMESTAMP WITH LOCAL TIME ZONE usage notes
In TIMESTAMP 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 WITH LOCAL TIME ZONE
and TIMESTAMP
, the session time zone is evaluated and the TIMESTAMP WITH LOCAL TIME ZONE
is transformed into a TIMESTAMP
data type. This is the same as displaying a TIMESTAMP WITH LOCAL TIME ZONE
value. For example, in your database client, the internal UTC normalized value is also converted to TIMESTAMP
data type, considering the session time zone.
TIME_ZONE_BEHAVIOR
While TIMESTAMP
is a simple structure consisting of a year, month, day, hour, minute, and second, data of type TIMESTAMP 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 WITH LOCAL TIME ZONE
. The literal for data type TIMESTAMP
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)
Function | Description |
---|---|
SYSTIMESTAMP
|
Returns the current timestamp, rendered in the database time zone (DB-TIMEZONE) |
CURRENT_TIMESTAMP
|
Returns the current timestamp, rendered in the session time zone (SESSION_TIMEZONE) |
LOCALTIMESTAMP
|
Equivalent to CURRENT_TIMESTAMP |
NOW()
|
Equivalent to CURRENT_TIMESTAMP |
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
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');
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. For more information, see ALTER SESSION / ALTER SYSTEM.