mysql varchar
当插入的字符数超过varchar(n)限制的长度时,字符会被截断,不会出错,但会有警告
mysql> create table aa(name varchar(12));
Query OK, 0 rows affected (0.06 sec)
mysql> insert into aa value('qwertyuiopasdf');
Query OK, 1 row affected, 1 warning (0.03 sec)
mysql> show warnings;
+---------+------+-------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------+
| Warning | 1265 | Data truncated for column 'name' at row 1 |
+---------+------+-------------------------------------------+
1 row in set (0.00 sec)
mysql> select * from aa;
+--------------+
| name |
+--------------+
| qwertyuiopas |
+--------------+