超过varchar定义长度


mysql> select version();
+------------+
| version() |
+------------+
| 5.1.73-log |
+------------+
1 row in set (0.00 sec)

mysql> show variables like 'collation_%';
+----------------------+-------------------+
| Variable_name | Value |
+----------------------+-------------------+
| collation_connection | latin1_swedish_ci |
| collation_database | latin1_swedish_ci |
| collation_server | latin1_swedish_ci |
+----------------------+-------------------+
3 rows in set (0.00 sec)

mysql> use lina;
Database changed
mysql> create table test(name varchar(2));
Query OK, 0 rows affected (0.03 sec)

mysql> insert into test values('an'),('a'),('abc');
Query OK, 3 rows affected, 1 warning (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 1

mysql> show warnings;
+---------+------+-------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------+
| Warning | 1265 | Data truncated for column 'name' at row 3 |
+---------+------+-------------------------------------------+
1 row in set (0.00 sec)

mysql> select * from test;
+------+
| name |
+------+
| an |
| a |
| ab |
+------+
3 rows in set (0.00 sec)

posted on 2014-09-07 09:33  zitong  阅读(555)  评论(0编辑  收藏  举报