Data types

A data type defines what kind of value a column in a database table can contain. This parameter tells MySQL the type of data that will be stored inside each table column, so MySQL can plan the size of databases and perform lookups and searches more effectively.

In the previous chapter we’ve defined the VARCHAR and CHAR data types. MySQL offers many additional data types, including string, numeric, and spatial data types. Here is a description of the most important ones:

  • CHAR – a fixed-length string.
  • VARCHAR – a variable-length string.
  • BINARY – a fixed-length binary string. Used to store strings of full bytes that do not have an associated character set (such as GIFs).
  • BLOB – a Binary Large OBject. Used for binary data in excess of 65,536 bytes in size.
  • INT – a standard integer numerical.
  • FLOAT – a single-precision floating point number.
  • DATE – a date value in YYYY-MM-DD format.
  • TIME – a time value in HH:MM:SS format.
  • DATETIME – a date and time value in YYYY-MM-DD HH:MM:SS format.
Geek University 2022