线上的MySQL
错误日志中遇到了以下问题1
Data truncation: BIGINT UNSIGNED value is out of range in `(database.tablename.fieldname)`
MySQL
版本为:1
2
3
4
5
6
7mysql> select version();
+------------+
| version() |
+------------+
| 5.6.21-log |
+------------+
1 row in set (0.00 sec)
引起这个错误的原因是sql
语句中对unsigned
字段进行了递减操作的结果为负数导致的,1
update database.tablename set fieldname=fieldname-num
而MySQL
的模式是默认的mode
:1
2
3
4
5
6
7mysql> show variables like 'sql_mode';
+---------------+------------------------+
| Variable_name | Value |
+---------------+------------------------+
| sql_mode | NO_ENGINE_SUBSTITUTION |
+---------------+------------------------+
1 row in set (0.00 sec)
解决方案有3种: