如果我有gender ENUM('m', 'f')
,输入类似于:
UPDATE person
SET gender = 'Z'
WHERE person_id = 1;
结果:
Query OK, 0 rows affected, 1 warning (0.06 sec)
Rows matched: 1 Changed: 0 Warnings: 1
+-----------+---------+--------+--------+------------+------------------+--------+-------+---------+-------------+
| person_id | fname | lname | gender | birth_date | street | city | state | country | postal_code |
+-----------+---------+--------+--------+------------+------------------+--------+-------+---------+-------------+
| 1 | William | Turner | | 1972-05-27 | 1225 Tremont St. | Boston | MA | USA | 02138 |
+-----------+---------+--------+--------+------------+------------------+--------+-------+---------+-------------+
警告是:
+---------+------+---------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------+
| Warning | 1265 | Data truncated for column 'gender' at row 1 |
+---------+------+---------------------------------------------+
如果提供了错误的值,如何防止查询完全执行?