MySQL Variables unique_checks 数据库 参数变量解释及正确配置使用

本站中文解释

unique_checks 是MySQL参数变量,用于控制是否启用唯一性约束(unique Constraints)的检查。

当unique_checks的值设置为1时,MySQL会检查表中的唯一性约束,确保所有的唯一键值都是不一样的,这在插入,更新和删除数据时,都会有影响。

当unique_checks的值设置为0时,MySQL不会检查唯一性约束,这样可以提高插入,更新和删除数据的速度,但是会带来数据完整性的问题。

要设置unique_checks,可以使用下面的SQL语句:

SET unique_checks=1; — 启用唯一性约束检查

SET unique_checks=0; — 禁用唯一性约束检查

官方英文解释

unique_checks

System Variable unique_checks
Scope Global, Session
Dynamic Yes
Type Boolean
Default Value ON

If set to 1 (the default), uniqueness checks for secondary
indexes in InnoDB tables are performed. If
set to 0, storage engines are permitted to assume that
duplicate keys are not present in input data. If you know for
certain that your data does not contain uniqueness violations,
you can set this to 0 to speed up large table imports to
InnoDB.

Setting this variable to 0 does not
require storage engines to ignore
duplicate keys. An engine is still permitted to check for them
and issue duplicate-key errors if it detects them.


数据运维技术 » MySQL Variables unique_checks 数据库 参数变量解释及正确配置使用