php 第 1 行的“xxxx”列的数据被截断
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2243922/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Data truncated for column 'xxxx' at row 1
提问by user187580
I have just moved a php site to a new server. One of my queries is failing with Data truncated for column 'xxx' ar row 1message. I checked that this field is float (10,6) type. And the values I provided white updating are not of exactly float(10,6) format and they vary .. like sometimes I put 0 only, or 54.56666 only .. so any idea how do I sort it out??
我刚刚将一个 php 站点移到了新服务器。我的一个查询失败并Data truncated for column 'xxx' ar row 1显示消息。我检查过这个字段是 float (10,6) 类型。我提供的白色更新的值不是完全浮点(10,6)格式,它们各不相同..就像有时我只放0,或只放54.56666..所以知道我该如何解决?
PS: On the earlier server, everything was working ok. This new server has different (newer) version of mysql. I don't want to make any changes to the mysql config.
PS:在较早的服务器上,一切正常。这个新服务器有不同(更新)版本的 mysql。我不想对 mysql 配置进行任何更改。
采纳答案by Gordon
You tried to put in data that was longer than what your column definitions allow. Please provide the queries you used for us to see. In addition googling the error message yielded:
您试图放入比列定义允许的更长的数据。请提供您用于我们查看的查询。此外谷歌搜索错误消息产生:
- http://forums.mysql.com/read.php?11,132672,132672#msg-132672
- http://forums.mysql.com/read.php?11,132672,132693#msg-132693
- http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html
- http://forums.mysql.com/read.php?11,132672,132672#msg-132672
- http://forums.mysql.com/read.php?11,132672,132693#msg-132693
- http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html
The suggested solution there is to modify the server's "strict mode" setting:
建议的解决方案是修改服务器的“严格模式”设置:
When this manual refers to “strict mode,” it means a mode where at least one of
STRICT_TRANS_TABLESorSTRICT_ALL_TABLESis enabled.
当本手册提到“严格模式”时,它表示至少启用了
STRICT_TRANS_TABLES或之一的模式STRICT_ALL_TABLES。
回答by MeatPopsicle
Also, if you have an enum and you insert a value not present in the enum you can see this error.
此外,如果您有一个枚举并且插入了一个不在枚举中的值,您会看到此错误。

