码迷,mamicode.com
首页 > 其他好文 > 详细

超过varchar定义长度

时间:2014-09-07 09:48:14      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:style   color   io   ar   strong   for   cti   sp   log   


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)

超过varchar定义长度

标签:style   color   io   ar   strong   for   cti   sp   log   

原文地址:http://www.cnblogs.com/lehao/p/3960125.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!