Basic data types

Updated at:

Lindorm SQL supports 14 data types for use in table definitions. This page lists each type with its storage size, Java mapping, and compatibility with Lindorm engines and indexes.

Applicable engines

The data types described here apply to LindormTable, LindormTSDB, and the columnar storage engine.

Supported data types

Boolean

Data typeJava typeSizeDescription
BOOLEANjava.lang.Boolean1 byteStores true or false.

Integer types

All integer types store exact numeric values. The value range is based on the value length and whether the values are signed.

Data typeJava typeSize
TINYINTjava.lang.Byte1 byte
SMALLINTjava.lang.Short2 bytes
INTEGERjava.lang.Integer4 bytes
BIGINTjava.lang.Long8 bytes

Floating-point types

FLOAT and DOUBLE store approximate numeric values. For financial data such as payment amounts, use DECIMAL instead.

Data typeJava typeSizeDescription
FLOATjava.lang.Float4 bytesStores approximate numeric values. The value range and precision depend on the value length, the precision and scale parameters, and whether the values are signed.
DOUBLEjava.lang.Double8 bytesStores approximate numeric values. The value range and precision depend on the value length, the precision and scale parameters, and whether the values are signed. All DOUBLE values in SQL statements must be expressed in scientific notation.

Exact numeric type

Data typeJava typeSizeDescription
DECIMAL(precision, scale)java.lang.BigDecimalVariableStores exact decimal values. The number of bytes increases with precision. Use DECIMAL for high-precision data such as payment amounts; use FLOAT or DOUBLE for data where approximate values are acceptable, such as monitoring data.

Parameters:

  • precision: Total number of digits. Valid values: 1–38.

  • scale: Number of decimal places. Valid values: 0 to the value of precision.

String types

Data typeJava typeDescription
VARCHARjava.lang.StringVariable-length string. Chinese characters are supported.
CHAR(N)java.lang.StringFixed-length string of N characters. Chinese characters are supported.

Binary types

Data typeJava typeDescription
BINARY(N)byte[]Fixed-length binary value of N bytes. If the input is shorter than N bytes, the system pads trailing zeroes. If the input exceeds N bytes, the system truncates the extra bytes.
VARBINARYbyte[]Variable-length binary value. If used as a primary key column, it must be the last primary key column.

Date and time types

Data typeJava typeRangeDescription
DATEjava.sql.Types#DATE—Stores date values only — time is discarded. DATE values are prone to errors during time zone conversion because the stored date is interpreted relative to the connection's time zone. Avoid this type when time zone correctness matters. See Background information.
TIMEjava.sql.Types#TIME—Stores time values. See Background information.
TIMESTAMPjava.sql.Types#TIMESTAMPUp to 9999-12-31 23:59:59 in Lindorm (up to 2038-01-19 03:14:07 in MySQL)Stores timestamp values. See Background information.
Important

The maximum TIMESTAMP value differs between MySQL and Lindorm. MySQL caps at 2038-01-19 03:14:07, while Lindorm supports values up to 9999-12-31 23:59:59.

Engine compatibility

The following table shows which data types each engine supports.

〇 = supported; N = not supported.
Data typeLindormTableLindormTSDBColumnar storage engine
BOOLEAN〇〇〇
TINYINT〇N〇
SMALLINT〇N〇
INTEGER〇N〇
BIGINT〇〇〇
FLOAT〇N〇
DOUBLE〇〇〇
DECIMAL(precision, scale)〇N〇
VARCHAR〇〇〇
CHAR(N)〇〇〇
BINARY(N)〇N〇
VARBINARY〇N〇
DATE〇N〇
TIME〇NN
TIMESTAMP〇〇〇

Index compatibility

To accelerate queries on raw data in LindormTable, you can create secondary indexes for point lookups, search indexes for full-text and multidimensional queries, or columnar indexes for analytical workloads. The following table shows which data types each index type supports.

〇 = supported; N = not supported.
Data typeSecondary indexSearch indexColumnar index
BOOLEAN〇〇〇
TINYINT〇〇〇
SMALLINT〇〇〇
INTEGER〇〇〇
BIGINT〇〇〇
FLOAT〇〇〇
DOUBLE〇〇〇
DECIMAL(precision, scale)〇N〇
VARCHAR〇〇〇
CHAR(N)〇〇〇
BINARY(N)〇〇〇
VARBINARY〇〇〇
DATE〇N〇
TIME〇NN
TIMESTAMP〇〇 (requires LindormTable 2.6.5 or later)〇