Data Types
SQL data type reference for Apache Phoenix.
Data Types
INTEGER Type
Possible values: -2147483648 to 2147483647.
Mapped to java.lang.Integer. The binary representation is a 4 byte integer with the sign bit flipped (so that negative values sorts before positive values).
Example
INTEGERUNSIGNED_INT Type
Possible values: 0 to 2147483647. Mapped to java.lang.Integer. The binary representation is a 4 byte integer, matching the Bytes.toBytes(int) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.
Example
UNSIGNED_INTBIGINT Type
Possible values: -9223372036854775808 to 9223372036854775807. Mapped to java.lang.Long. The binary representation is an 8 byte long with the sign bit flipped (so that negative values sorts before positive values).
Example
BIGINTUNSIGNED_LONG Type
Possible values: 0 to 9223372036854775807. Mapped to java.lang.Long. The binary representation is an 8 byte integer, matching the Bytes.toBytes(long) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.
Example
UNSIGNED_LONGTINYINT Type
Possible values: -128 to 127. Mapped to java.lang.Byte. The binary representation is a single byte, with the sign bit flipped (so that negative values sorts before positive values).
Example
TINYINTUNSIGNED_TINYINT Type
Possible values: 0 to 127. Mapped to java.lang.Byte. The binary representation is a single byte, matching the Bytes.toBytes(byte) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.
Example
UNSIGNED_TINYINTSMALLINT Type
Possible values: -32768 to 32767. Mapped to java.lang.Short. The binary representation is a 2 byte short with the sign bit flipped (so that negative values sort before positive values).
Example
SMALLINTUNSIGNED_SMALLINT Type
Possible values: 0 to 32767. Mapped to java.lang.Short. The binary representation is an 2 byte integer, matching the Bytes.toBytes(short) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.
Example
UNSIGNED_SMALLINTFLOAT Type
Possible values: -3.402823466 E + 38 to 3.402823466 E + 38. Mapped to java.lang.Float. The binary representation is an 4 byte float with the sign bit flipped (so that negative values sort before positive values).
Example
FLOATUNSIGNED_FLOAT Type
Possible values: 0 to 3.402823466 E + 38. Mapped to java.lang.Float. The binary representation is an 4 byte float matching the Bytes.toBytes(float) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.
Example
UNSIGNED_FLOATDOUBLE Type
Possible values: -1.7976931348623158 E + 308 to 1.7976931348623158 E + 308. Mapped to java.lang.Double. The binary representation is an 8 byte double with the sign bit flipped (so that negative values sort before positive value).
Example
DOUBLEUNSIGNED_DOUBLE Type
Possible values: 0 to 1.7976931348623158 E + 308. Mapped to java.lang.Double. The binary representation is an 8 byte double matching the Bytes.toBytes(double) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.
Example
UNSIGNED_DOUBLEDECIMAL Type
Data type with fixed precision and scale. A user can specify precision and scale by expression DECIMAL(precision,scale) in a DDL statement, for example, DECIMAL(10,2). The maximum precision is 38 digits. Mapped to java.math.BigDecimal. The binary representation is binary comparable, variable length format. When used in a row key, it is terminated with a null byte unless it is the last column.
Example
DECIMAL
DECIMAL(10,2)BOOLEAN Type
Possible values: TRUE and FALSE.
Mapped to java.lang.Boolean. The binary representation is a single byte with 0 for false and 1 for true
Example
BOOLEANTIME Type
The time data type. The format is yyyy-MM-dd hh:mm:ss, with both the date and time parts maintained. Mapped to java.sql.Time. The binary representation is an 8 byte long (the number of milliseconds from the epoch), making it possible (although not necessarily recommended) to store more information within a TIME column than what is provided by "java.sql.Time". Note that the internal representation is based on a number of milliseconds since the epoch (which is based on a time in GMT), while "java.sql.Time" will format times based on the client's local time zone. Please note that this TIME type is different than the TIME type as defined by the SQL 92 standard in that it includes year, month, and day components. As such, it is not in compliance with the JDBC APIs. As the underlying data is still stored as a long, only the presentation of the value is incorrect.
Example
TIMEDATE Type
The date data type. The format is yyyy-MM-dd hh:mm:ss, with both the date and time parts maintained to a millisecond accuracy. Mapped to java.sql.Date. The binary representation is an 8 byte long (the number of milliseconds from the epoch), making it possible (although not necessarily recommended) to store more information within a DATE column than what is provided by "java.sql.Date". Note that the internal representation is based on a number of milliseconds since the epoch (which is based on a time in GMT), while "java.sql.Date" will format dates based on the client's local time zone. Please note that this DATE type is different than the DATE type as defined by the SQL 92 standard in that it includes a time component. As such, it is not in compliance with the JDBC APIs. As the underlying data is still stored as a long, only the presentation of the value is incorrect.
Example
DATETIMESTAMP Type
The timestamp data type. The format is yyyy-MM-dd hh:mm:ss[.nnnnnnnnn]. Mapped to java.sql.Timestamp with an internal representation of the number of nanos from the epoch. The binary representation is 12 bytes: an 8 byte long for the epoch time plus a 4 byte integer for the nanos. Note that the internal representation is based on a number of milliseconds since the epoch (which is based on a time in GMT), while "java.sql.Timestamp" will format timestamps based on the client's local time zone.
Example
TIMESTAMPUNSIGNED_TIME Type
The unsigned time data type. The format is yyyy-MM-dd hh:mm:ss, with both the date and time parts maintained to the millisecond accuracy. Mapped to java.sql.Time. The binary representation is an 8 byte long (the number of milliseconds from the epoch) matching the HBase.toBytes(long) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.
Example
UNSIGNED_TIMEUNSIGNED_DATE Type
The unsigned date data type. The format is yyyy-MM-dd hh:mm:ss, with both the date and time parts maintained to a millisecond accuracy. Mapped to java.sql.Date. The binary representation is an 8 byte long (the number of milliseconds from the epoch) matching the HBase.toBytes(long) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.
Example
UNSIGNED_DATEUNSIGNED_TIMESTAMP Type
The timestamp data type. The format is yyyy-MM-dd hh:mm:ss[.nnnnnnnnn]. Mapped to java.sql.Timestamp with an internal representation of the number of nanos from the epoch. The binary representation is 12 bytes: an 8 byte long for the epoch time plus a 4 byte integer for the nanos with the long serialized through the HBase.toBytes(long) method. The purpose of this type is to map to existing HBase data that was serialized using this HBase utility method. If that is not the case, use the regular signed type instead.
Example
UNSIGNED_TIMESTAMPVARCHAR Type
A variable length String with an optional max byte length. The binary representation is UTF8 matching the Bytes.toBytes(String) method. When used in a row key, it is terminated with a null byte unless it is the last column.
Mapped to java.lang.String.
Example
VARCHAR
VARCHAR(255)CHAR Type
A fixed length String with single-byte characters. The binary representation is UTF8 matching the Bytes.toBytes(String) method.
Mapped to java.lang.String.
Example
CHAR(10)BINARY Type
Raw fixed length byte array.
Mapped to byte[].
Example
BINARYVARBINARY Type
Raw variable length byte array.
Mapped to byte[].
Example
VARBINARYARRAY
Mapped to java.sql.Array. Every primitive type except for VARBINARY may be declared as an ARRAY. Only single dimensional arrays are supported.
Example
VARCHAR ARRAY
CHAR(10) ARRAY [5]
INTEGER []
INTEGER [100]