MySql 中文参考指南

Chapter 13 Data Types

目录

Table of Contents

MySQL 在多个类别中支持 SQL 数据类型:数字类型、日期和时间类型、字符串(字符和字节)类型、空间类型和 JSON 数据类型。本章概述并更详细地介绍了每个类别中类型的属性,并总结了数据类型的存储需求。最初的概述故意简洁。有关特定数据类型的更多信息的说明中,请查看格式的详细信息,例如您可以指定值的允许格式。

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:

  1. 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.

  2. 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.

  3. 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.)

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