MySQL Datatypes

MySQL version 5.1 has support for spatial data, but not as datatypes. Spatial data is handled in a variety of classes provided in the OpenGIS Geometry Model, which is supported by the MyISAM, InnoDB, NDB, and ARCHIVE database engines. Only MyISAM supports both spatial and non-spatial indexes; the other database engines only support non-spatial indexes.

MySQL numeric datatypes support the following optional attributes:

UNSIGNED

The numeric value is assumed to be non-negative (positive or zero). For fixed-point datatypes such as DECIMAL and NUMERIC, the space normally used to show a positive or negative condition of the numeric value can be used as part of the value, providing a little extra numeric range in the column for these types. (There is no SIGNED optional attribute.)

ZEROFILL

Used for display formatting, this attribute tells MySQL that the numeric value is padded to its full size with zeros rather than spaces. ZEROFILL automatically forces the UNSIGNED attribute as well.

MySQL also enforces a maximum display size for columns of up to 255 characters. Columns longer than 255 characters are stored properly, but only 255 characters are displayed. Floating-point numeric datatypes may have a maximum of 30 digits after the decimal point.

The following list enumerates the datatypes MySQL supports. These include most of the SQL2003 datatypes, plus several additional datatypes used to contain lists of values, as well as datatypes used for binary large objects (BLOBs). Datatypes ...

Get SQL in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.