Doc Menu

You are viewing the documentation of an older version of the TiDB database (TiDB v3.0).

It is recommended that you use the latest stable version of the TiDB database.

Data Types

TiDB supports all the data types in MySQL except the SPATIAL type. This includes all the numeric types, string types, date & time types, and the JSON type.

The definitions used for datatypes are specified as T(M[, D]). Where by:

  • T indicates the specific data type.
  • M indicates the maximum display width for integer types. For floating-point and fixed-point types, M is the total number of digits that can be stored (the precision). For string types, M is the maximum length. The maximum permissible value of M depends on the data type.
  • D applies to floating-point and fixed-point types and indicates the number of digits following the decimal point (the scale).
  • fsp applies to the TIME, DATETIME, and TIMESTAMP types and represents the fractional seconds precision. The fsp value, if given, must be in the range 0 to 6. A value of 0 signifies that there is no fractional part. If omitted, the default precision is 0.