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.
boolean: A Boolean data type that can only have a value of0 or 1. A value of 0 representsfalse, and a value of 1 representstrue. This data type is stored as 1 bit.tinyint: A tiny integer type. Value range:-128 to 127smallintis a 2 byte integer data type with a value range of-32768 to 32767.int: An integer type. Value range:-2147483648 to 2147483647bigint: A big integer type. Value range:-9223372036854775808 to 9223372036854775807floatis 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, and1.175494351E-38 to 3.402823466E+38.double: An 8-byte, IEEE-compliant, double-precision floating-point number. The value range is-1.7976931348623157E+308 to -2.2250738585072014E-308,0, or2.2250738585072014E-308 to 1.7976931348623157E+308.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 tomvarchar: A variable-length string type.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.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.timestampdata type has a value range from'1970-01-01 00:00:01' UTCto'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 type | MySQL data type | Difference |
| boolean | bool, boolean | Same. |
| tinyint | tinyint | Same. |
| smallint | smallint | Same. |
| int | int, integer | Same. |
| bigint | bigint | Same. |
| float | float[(m,d)] | AnalyticDB for MySQL does not support custom m and d values. MySQL supports them. |
| double | double[(m,d)] | AnalyticDB for MySQL does not support custom m and d values. MySQL supports them. |
| decimal | decimal | The maximum precision for AnalyticDB for MySQL is 1000. The maximum precision for MySQL is 65. |
| varchar | varchar | AnalyticDB for MySQL has a length limit. |
| date | date | Same. |
| time | time | The value ranges are different. |
| timestamp | timestamp | AnalyticDB 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.Is this page helpful?