我创建了一个带有 UTF-8 的表VARCHAR(5000)
,并用数据填充了它。但看起来这个字段允许的数据比它被指示的要多:
mysql> DESCRIBE test;
+---------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| comment | varchar(5000) | YES | | NULL | |
+---------+------------------+------+-----+---------+----------------+
2 rows in set (0.01 sec)
mysql> SELECT MAX(LENGTH(comment)) FROM test;
+----------------------+
| MAX(LENGTH(comment)) |
+----------------------+
| 5001 |
+----------------------+
1 row in set (0.01 sec)
这是为什么?