Data types (Version 2.0)

Updated at:
Copy as MD

A `varchar` field cannot exceed 16 KB in length. Otherwise, the field value may become null. If a column value exceeds 16 KB and you cannot filter out the data, you can remove the index from the column or create a full-text index for it. After you remove the index, do not use the column for filtering or calculations in queries.

  1. boolean: A Boolean data type that can only have a value of 0 or 1. A value of 0 represents false, and a value of 1 represents true. This data type is stored as 1 bit.
  2. tinyint: A tiny integer type. Value range: -128 to 127
  3. smallint is a 2 byte integer data type with a value range of -32768 to 32767.
  4. int: An integer type. Value range: -2147483648 to 2147483647
  5. bigint: A big integer type. Value range: -9223372036854775808 to 9223372036854775807
  6. float is a single-precision floating-point number that complies with the IEEE standard, uses 4 bytes of storage, and has a value range of -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38.
  7. double: An 8-byte, IEEE-compliant, double-precision floating-point number. The value range is -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, or 2.2250738585072014E-308 to 1.7976931348623157E+308.
  8. decimal(m,d)m1-1000d: m is the maximum precision of the value, with a value range of 1-1000. d is the number of digits to the right of the decimal point, and d must be less than or equal to m
  9. varchar: A variable-length string type.
  10. date: A date data type in the 'YYYY-MM-DD' format with a value range of '1000-01-01' to '9999-12-31'. The storage size is 4 bytes.
  11. time: A time data type. The value range is from '00:00:00' to '23:59:59', the data format is 'HH:MM:SS', and the storage size is 4 bytes.
  12. timestamp data type has a value range from '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC, supports the 'YYYY-MM-DD HH:MM:SS' data format, and uses 4 bytes of storage.

Comparison with MySQL data types

AnalyticDB for MySQL data typeMySQL data typeDifference
booleanbool, booleanSame.
tinyinttinyintSame.
smallintsmallintSame.
intint, integerSame.
bigintbigintSame.
floatfloat[(m,d)]AnalyticDB for MySQL does not support custom m and d values. MySQL supports them.
doubledouble[(m,d)]AnalyticDB for MySQL does not support custom m and d values. MySQL supports them.
decimaldecimalThe maximum precision for AnalyticDB for MySQL is 1000. The maximum precision for MySQL is 65.
varcharvarcharAnalyticDB for MySQL has a length limit.
datedateSame.
timetimeThe value ranges are different.
timestamptimestampAnalyticDB for MySQL is accurate to the second. MySQL supports custom precision.

Notes

A `varchar` field cannot exceed 16 KB in length. Otherwise, the field value may become null. If a column value exceeds 16 KB and you cannot filter out the data, you can remove the index or create a full-text index.