### 24.6.3 与函数相关的分区限制

本节讨论 MySQL 分区中与分区表达式中使用的函数相关的限制。

[](<>)

分区表达式中仅允许使用以下列表中显示的 MySQL 函数：

-   [`ABS()`](mathematical-functions.html#function_abs)

-   [`天花板（）`](mathematical-functions.html#function_ceiling)（看[天花板（）和地板（）](partitioning-limitations-functions.html#partitioning-limitations-ceiling-floor))

-   [`日期判断（）`](date-and-time-functions.html#function_datediff)

-   [`日（）`](date-and-time-functions.html#function_day)

-   [`DAYOFMONTH()`](date-and-time-functions.html#function_dayofmonth)

-   [`星期几（）`](date-and-time-functions.html#function_dayofweek)

-   [`年份（）`](date-and-time-functions.html#function_dayofyear)

-   [`提炼（）`](date-and-time-functions.html#function_extract)（看[带有 WEEK 说明符的 EXTRACT() 函数](partitioning-limitations-functions.html#partitioning-limitations-extract))

-   [`地面（）`](mathematical-functions.html#function_floor)（看[天花板（）和地板（）](partitioning-limitations-functions.html#partitioning-limitations-ceiling-floor))

-   [`小时（）`](date-and-time-functions.html#function_hour)

-   [`微秒（）`](date-and-time-functions.html#function_microsecond)

-   [`分钟（）`](date-and-time-functions.html#function_minute)

-   [`模组（）`](mathematical-functions.html#function_mod)

-   [`月（）`](date-and-time-functions.html#function_month)

-   [`25美分硬币（）`](date-and-time-functions.html#function_quarter)

-   [`第二（）`](date-and-time-functions.html#function_second)

-   [`TIME_TO_SEC()`](date-and-time-functions.html#function_time-to-sec)

-   [`TO_DAYS()`](date-and-time-functions.html#function_to-days)

-   [`TO_SECONDS()`](date-and-time-functions.html#function_to-seconds)

-   [`UNIX_TIMESTAMP()`](date-and-time-functions.html#function_unix-timestamp)（和[`时间戳`](datetime.html)列）

-   [`平日（）`](date-and-time-functions.html#function_weekday)

-   [`年（）`](date-and-time-functions.html#function_year)

-   [`年周（）`](date-and-time-functions.html#function_yearweek)

    MySQL 8.0 支持分区剪枝[`TO_DAYS()`](date-and-time-functions.html#function_to-days),[`TO_SECONDS()`](date-and-time-functions.html#function_to-seconds),[`年（）`](date-and-time-functions.html#function_year)， 和[`UNIX_TIMESTAMP()`](date-and-time-functions.html#function_unix-timestamp)职能。看[第 24.4 节，“分区修剪”](partitioning-pruning.html)， 了解更多信息。

[](<>)**天花板（）和地板（）。**这些函数中的每一个仅在传递一个精确数字类型的参数时才返回一个整数，例如[`INT`](integer-types.html)类型或[`十进制`](fixed-point-types.html).这意味着，例如，以下[`创建表`](create-table.html)语句失败并出现错误，如下所示：

```
mysql> CREATE TABLE t (c FLOAT) PARTITION BY LIST( FLOOR(c) )(
    ->     PARTITION p0 VALUES IN (1,3,5),
    ->     PARTITION p1 VALUES IN (2,4,6)
    -> );
ERROR 1490 (HY000): The PARTITION function returns the wrong type
```

[](<>)**带有 WEEK 说明符的 EXTRACT() 函数。**由返回的值[`提炼（）`](date-and-time-functions.html#function_extract)功能，当用作[`摘录（从*周开始`山口`*)`](date-and-time-functions.html#function_extract), 取决于[`default_week_format`](server-system-variables.html#sysvar_default_week_format)系统变量。为此原因，[`提炼（）`](date-and-time-functions.html#function_extract)当它指定单位为时，不允许作为分区函数`星期`.（错误 #54483）

看[第 12.6.2 节，“数学函数”](mathematical-functions.html)，有关这些函数的返回类型的更多信息，以及[第 11.1 节，“数值数据类型”](numeric-types.html).
