A data type is a classification of data that determines the type of value a variable possesses and the types of mathematical, relational, or logical operations that can be performed on it. Spice supports the following SQL data types: numeric, string and binary, boolean, date and time, and semi-structured.
Spice supports the following SQL data types.
Category | Data Type | Notes | Examples |
---|---|---|---|
Numeric Data Types | DECIMAL | A DECIMAL type has precision (
| 987.65 is a DECIMAL(5, 2) value |
INT | A 4-byte signed integer. The supported range is from -2147483648 to 2147483647 . | 5135 | |
BIGINT | An 8-byte signed integer. The supported range is from -9223372036854775808 to 9223372036854775807 . | -749826542587 | |
FLOAT | A 4-byte single-precision floating point. A FLOAT provides six decimal digits of precision. | 123.123456 | |
DOUBLE | 8-byte double-precision floating point. A DOUBLE provides 15 decimal digits of precision. | 123.123456789012345 | |
String & Binary Data Types | VARCHAR | VARCHAR stands for variable-length character string. By default, the maximum allowed length is 32,000 bytes. VARCHAR supports only UTF-8 encoded values. | 18852367854 |
VARBINARY | VARBINARY stands for variable-length binary string. By default, the maximum allowed length is 32,000 bytes. The value must be entered as a string value. |
-- | |
Boolean Data Type | BOOLEAN | The supported values for BOOLEAN include true, false, and null. | TRUE , FALSE , and NULL |
Date & Time Data Types | DATE | A date value that enables you to calculate and store consistent information about the date of the events and transactions. Note: When using a string literal for the date, | DATE ‘2000-01-01’ |
TIME | Identifies the time of day, which enables you to calculate and store consistent information about the time of the events and transactions. Note: When using a string literal for the time, | TIME ‘17:30:50.235’ TIME ‘17:30:50’ | |
TIMESTAMP | Represents an absolute point in time with millisecond precision without a time zone. Timestamps are truncated to the nearest millisecond. |
| |
INTERVAL (day to seconds) INTERVAL (years to months) | Intervals are used to represent a measure of time. Spice supports the two available types of intervals: year-month, which stores the year and month (YYYY-MM); and day-time (DD HH:MM:SS), which stores the days, hours, minutes, and seconds. Additionally, the following forms are supported:
|
| |
Semi-structured Data Types | STRUCT | Used to represent collections of key-value pairs. Keys are non-empty, case-insensitive strings, and values can be of any type. The example shows the required format for a query where the key ( Note: Spice does not have STRUCT literals, but you can get the same result using
-- | SELECT address['city'] FROM customerTable . |
LIST | Used to represent a list of arbitrary size, where the index is a non-negative integer and values can be of any type. The example shows the required format for a query where the index ( Note: Spice does not have LIST literals, but you can get the same result using
-- | SELECT customerOrders[100] FROM OrderHistoryTable | |
MAP | The MAP type is a collection of key-value pairs. MAP keys are case-insensitive strings. All values in a given map have the same type. For example, map<string, int> represents a mapping where the keys are strings and the values are integers. To retrieve the value of a MAP element, use column['key'] syntax: SELECT <column_name['<key_name>']> FROM <table_name> . For information about the SQL functions that are available for MAP expressions, see Datatype. | SELECT address['city'] FROM customerTable |