// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements.  See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License.  You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
= Data Types


The page contains a list of SQL data types available in Ignite such as string, numeric, and date/time types.

Every SQL type is mapped to a programming language or driver specific type that is supported by Ignite natively.

== Boolean Types

=== BOOLEAN
Possible values: `TRUE` and `FALSE`.

== Numeric Types

=== TINYINT

Possible values: `[-128, 127]`.

=== SMALLINT
Possible values: [`-32768`, `32767`].

=== INT

Possible values: [`-2147483648`, `2147483647`].

Alias: `INTEGER`

=== BIGINT
Possible values: [`-9223372036854775808`, `9223372036854775807`].

=== DECIMAL
Possible values: Exact number of selectable precision.

Default precision: `32767`

Maximum precision: `32767`

Default scale: `0`

Maximum scale: `16383`

==== Decimal Precision and Scale in Ignite

Ignite has the following specifics when handling decimal values:

- You can specify scale that is larger than precision. In this case, the column will only hold fractional values, and the number of 0 digits to the right of the decimal point must be the same as scale minus precision. For example if you use the following declaration:
+
[source, sql]
----
NUMERIC(3, 6)
----
+
You can store values between -0.000999 and 0.000999, inclusive.
+
- `BigDecimal` data type is derived as `DECIMAL(28, 6)`. If there are more than 6 digits after the decimal point, they will be dropped.  If a value larger than precision is passed, out of range exception will occur.
+
To store larger decimal values, cast them with custom precision, for example `CAST(? as DECIMAL(100, 50))`.


=== FLOAT

Possible values: A single precision (32-bit) IEEE 754 floating-point number.

Alias: `REAL`

Special values: `NaN`, `-Infinity`, `+Infinity`

=== DOUBLE
Possible values: A double precision (64-bit) IEEE 754 floating-point number.

Alias: `DOUBLE PRECISION`

Special values: `NaN`, `-Infinity`, `+Infinity`

== Character String Types

=== VARCHAR
Possible values: A Unicode string.

Alias: `CHARACTER VARYING`

Default length: `65536`

Maximum length: `65536`

=== CHAR

Fixed length Unicode string padded with spaces.

Default length: `1`

Maximum length: `65536`

NOTE: This type can only be used in expressions (such as CAST(‘a’ AS CHAR(3)) and it cannot be used in DDL statements such as CREATE TABLE, ALTER TABLE ADD COLUMN, etc. Use <<VARCHAR>> instead.

== Binary String Types

=== VARBINARY

Possible values: binary data (“byte array”).

Aliases: `BINARY`, `BINARY VARYING`

Default length: `65536`

Maximum length: `65536`

== Date and Time Types

=== TIME
Possible values: [`00-00-00`, `23-59-59.999`].

The format is `HH:mm:ss[.SSS]`.

Default precision: `0`

Maximum precision: `3`

=== DATE
Possible values: [`0001-01-01`, `9999-12-31`].

The format is `yyyy-MM-dd`.

=== TIMESTAMP

WARNING: The timestamp data type only supports precision up to milliseconds (3 symbols). Any values past the 3rd symbol will be ignored.

Possible values: [`0001-01-01 18:00:00`, `9999-12-31 05:59:59.999`].

The format is `yyyy-MM-dd HH:mm:ss[.SSS]`.

Default precision: `6`

Maximum precision: `9`

=== TIMESTAMP WITH LOCAL TIME ZONE

WARNING: The timestamp with local time zone data type only supports precision up to milliseconds (3 symbols). Any values past the 3rd symbol will be ignored.

Unlike `TIMESTAMP`, the value is always stored in UTC time zone.
The value passed to/from the user is converted from/to UTC using the user's session time zone.

Possible values (in UTC time zone): [`0001-01-01 18:00:00`, `9999-12-31 05:59:59.999`].

The format is `yyyy-MM-dd HH:mm:ss[.SSS]`.

Default precision: `6`

Maximum precision: `9`

== Other Types

=== UUID
Possible values: Universally unique identifier. This is a 128 bit value.

Example UUID: `7d24b70e-25d5-45ed-a5fa-39d8e1d966b9`

== Implicit Type Conversion

In Ignite 3, implicit type conversion is limited to types within the same type family. The table below covers the possible implicit conversions:

[cols="1,3",opts="header"]
|===
|Type Family
|Available Types


|Boolean
|`BOOLEAN`

|Numeric
|`TINYINT`,
`SMALLINT`,
`INT`,
`BIGINT`,
`DECIMAL`,
`FLOAT`,
`DOUBLE`

|Character String
|`VARCHAR`,
`CHAR`

|Binary String
|`VARBINARY`
`BINARY`

|Date
|`DATE`

|Time
|`TIME`

|Datetime
|`TIMESTAMP`,
`TIMESTAMP WITH LOCAL TIME ZONE`

|UUID
|`UUID`

|===