Chapter 11 Data Types Table of Contents MySQL supports SQL data types in several categories: numeric types, date and time types, string (character and byte) types, spatial types, and the  JSON  data type. This chapter provides an overview and more detailed description of the properties of the types in each category, and a summary of the data type storage requirements. The initial overviews are intentionally brief. Consult the more detailed descriptions 2011 11.1 Numeric Data Types ............................................................................................................. 2012 11.1.1 Numeric Data Type Syntax ......................................................................................... 2012 11.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT ................................................................................................................................. 2016 11.1.3 Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC .............................................. 2017 11.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE ...................................... 2017 11.1.5 Bit-Value Type - BIT ................................................................................................... 2018 11.1.6 Numeric Type Attributes ............................................................................................. 2018 11.1.7 Out-of-Range and Overflow Handling .......................................................................... 2019 11.2 Date and Time Data Types ................................................................................................... 2021 11.2.1 Date and Time Data Type Syntax ............................................................................... 2022 11.2.2 The DATE, DATETIME, and TIMESTAMP Types ......................................................... 2024 11.2.3 The TIME Type .......................................................................................................... 2027 11.2.4 The YEAR Type ......................................................................................................... 2028 11.2.5 Automatic Initialization and Updating for TIMESTAMP and DATETIME .......................... 2029 11.2.6 Fractional Seconds in Time Values ............................................................................. 2032 11.2.7 Conversion Between Date and Time Types ................................................................. 2033 11.2.8 2-Digit Years in Dates ................................................................................................ 2034 11.3 String Data Types ................................................................................................................. 2034 11.3.1 String Data Type Syntax ............................................................................................. 2035 11.3.2 The CHAR and VARCHAR Types ............................................................................... 2039 11.3.3 The BINARY and VARBINARY Types ......................................................................... 2040 11.3.4 The BLOB and TEXT Types ....................................................................................... 2041 11.3.5 The ENUM Type ........................................................................................................ 2043 11.3.6 The SET Type ........................................................................................................... 2046 11.4 Spatial Data Types ............................................................................................................... 2048 11.4.1 Spatial Data Types ..................................................................................................... 2050 11.4.2 The OpenGIS Geometry Model ................................................................................... 2051 11.4.3 Supported Spatial Data Formats ................................................................................. 2057 11.4.4 Geometry Well-Formedness and Validity ..................................................................... 2060 11.4.5 Spatial Reference System Support .............................................................................. 2061 11.4.6 Creating Spatial Columns ........................................................................................... 2062 11.4.7 Populating Spatial Columns ........................................................................................ 2062 11.4.8 Fetching Spatial Data ................................................................................................. 2063 11.4.9 Optimizing Spatial Analysis ......................................................................................... 2064 11.4.10 Creating Spatial Indexes ........................................................................................... 2064 11.4.11 Using Spatial Indexes ............................................................................................... 2065 11.5 The JSON Data Type ........................................................................................................... 2067 11.6 Data Type Default Values ..................................................................................................... 2084 11.7 Data Type Storage Requirements .......................................................................................... 2087 11.8 Choosing the Right Type for a Column .................................................................................. 2091 11.9 Using Data Types from Other Database Engines .................................................................... 2091