# 概述

MySQL 支持几种类别的 [SQL](https://dev.mysql.com/doc/refman/8.0/en/glossary.html#glos_sql) 数据类型：数值类型、“日期和时间”类型、字符串（字符和字节）类型、空间类型和 [JSON](https://dev.mysql.com/doc/refman/8.0/en/json.html) 数据类型。本章阐述了每个类别所含类型的属性，以及总结了数据类型的存储要求。

数据类型的描述使用了以下约定：

* 对于整型（integer），`M` 表示最大的显示宽度（display width）；对于浮点型（floating-point）和定点型（fixed-point）类型，`M` 表示可被存储数字的总个数（the precision）；对于字符串类型，`M` 是最大长度。另外，`M` 的最大允许值取决于具体的数据类型。
* `D` 应用于浮点型和定点型，它表示小数点后可存在多少个数字（the scale）。可能的最大值为 30，但不应大于 `M`-2。
* `fsp` 应用于 TIME、DATETIME 和 TIMESTAMP 类型，它表示小数的精度（即毫秒、微秒），即小数点后数字的个数。`fsp` 的取值范围为 \[0, 6]，其中 0 表示没有小数。若缺省（即不传递该参数），默认精度为 0（与 SQL 标准的默认值 6 不同，主要为了兼容 MySQL 旧版本）。
* 方括号（\[]）表示类型定义的可选部分。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jchehe.gitbook.io/mysql_data_types_cn/gai-shu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
