Documentation Home
MySQL 9.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 40.0Mb
PDF (A4) - 40.1Mb
Man Pages (TGZ) - 258.8Kb
Man Pages (Zip) - 365.9Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb


MySQL 9.0 Reference Manual  /  Data Types

Chapter 13 Data Types

Table of Contents

13.1 Numeric Data Types
13.1.1 Numeric Data Type Syntax
13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT
13.1.3 Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC
13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE
13.1.5 Bit-Value Type - BIT
13.1.6 Numeric Type Attributes
13.1.7 Out-of-Range and Overflow Handling
13.2 Date and Time Data Types
13.2.1 Date and Time Data Type Syntax
13.2.2 The DATE, DATETIME, and TIMESTAMP Types
13.2.3 The TIME Type
13.2.4 The YEAR Type
13.2.5 Automatic Initialization and Updating for TIMESTAMP and DATETIME
13.2.6 Fractional Seconds in Time Values
13.2.7 What Calendar Is Used By MySQL?
13.2.8 Conversion Between Date and Time Types
13.2.9 2-Digit Years in Dates
13.3 String Data Types
13.3.1 String Data Type Syntax
13.3.2 The CHAR and VARCHAR Types
13.3.3 The BINARY and VARBINARY Types
13.3.4 The BLOB and TEXT Types
13.3.5 The VECTOR Type
13.3.6 The ENUM Type
13.3.7 The SET Type
13.4 Spatial Data Types
13.4.1 Spatial Data Types
13.4.2 The OpenGIS Geometry Model
13.4.3 Supported Spatial Data Formats
13.4.4 Geometry Well-Formedness and Validity
13.4.5 Spatial Reference System Support
13.4.6 Creating Spatial Columns
13.4.7 Populating Spatial Columns
13.4.8 Fetching Spatial Data
13.4.9 Optimizing Spatial Analysis
13.4.10 Creating Spatial Indexes
13.4.11 Using Spatial Indexes
13.5 The JSON Data Type
13.6 Data Type Default Values
13.7 Data Type Storage Requirements
13.8 Choosing the Right Type for a Column
13.9 Using Data Types from Other Database Engines

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 for additional information about particular data types, such as the permissible formats in which you can specify values.

Data type descriptions use these conventions:

  • For integer types, M indicates the maximum display width. 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). The maximum possible value is 30, but should be no greater than M−2.

  • fsp applies to the TIME, DATETIME, and TIMESTAMP types and represents fractional seconds precision; that is, the number of digits following the decimal point for fractional parts of seconds. 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. (This differs from the standard SQL default of 6, for compatibility with previous MySQL versions.)

  • Square brackets ([ and ]) indicate optional parts of type definitions.