CQL data types are mapped to Java data types.
The following table shows the mapping between CQL data types and Java data types.
Table 3-5 Mapping between CQL data types and Java data types
Class | CQL data type | Data format | Java data type | Data range | Remarks |
---|---|---|---|---|---|
Numeric data | INT[EGER] | Integer, 4 bytes | Integer class | -2,147,483,648 through 2,147,483,647 | -- |
SMALLINT | Integer, 2 bytes | Short class | -32,768 through 32,767 | -- | |
TINYINT | Integer, 1 byte | Byte class | -128 through 127 | -- | |
BIGINT | Integer, 8 bytes | Long class | -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807 | -- | |
DEC[IMAL]['('m')']#1 | Decimal format | java.math.BigDecimal class | -1038+1 through 1038-1 | Decimal number whose precision (the total number of digits) is m digits (not including the + or - sign). m is a positive integer in the range of 1 ![]() ![]() | |
NUMERIC['('m')']#1 | |||||
REAL | Real number, 4 bytes | Float class |
| Data cannot be input using an exponential expression | |
FLOAT | Real number, 8 bytes | Double class |
| Data cannot be input using an exponential expression | |
DOUBLE | |||||
Character data | CHAR[ACTER]['('n')'] | Fixed-length character string (with n characters) | java.lang.String class | 1 to 255 characters | n is a positive integer in the range of 1 ![]() ![]() |
VARCHAR'('n')' | Variable-length character string (with the maximum of n characters) | 1 to 32,767 characters | n is a positive integer in the range of 1 ![]() ![]() | ||
Date data | DATE#2 | Date (year-month-day) | java.sql.Date class | YYYYMMDD YYYY: 0001 to 9999 (Year) MM: 01 to 12 (Month) DD: 01 to the last day of the applicable month (Day) | -- |
Time data | TIME#2 | Time (hour-minutes-seconds) | java.sql.Time class | hhmmss hh: 00 to 23 (hour) mm: 00 to 59 (minutes) ss: 00 to 59 (seconds) | -- |
Timestamp data | TIMESTAMP['('p')']#2 | Date and time (year-month-day + hour-minutes-seconds + nanoseconds) | java.sql.Timestamp class | YYYYMMDDhhmmss[nn....n] YYYY: 0001 to 9999 (Year) MM: 01 to 12 (Month) DD: 01 to the last day of the applicable month (Day) hh: 00 to 23 (hour) mm: 00 to 59 (minutes) ss: 00 to 59 (seconds) nn....n: p-digit fractional seconds (n: 0 to 9) | p is a positive integer. n is in the range of 0 ![]() ![]() If the number of digits in p is 3, 6, or 9, time is being specified in 1-millisecond, 1-microsecond, or 1-nanosecond units, respectively. If the specified data exceeds p, an error occurs. |