开发者

`id` int(10) NOT NULL auto_increment

Some scripts I migrated are doing lots of

INSERT INTO `table` ( `id` , `fld2` , `fld3`) VALUES ( '', 'v2', 'v3')

id is defined as: int(10) NOT NULL auto_increment.

My database/mysql server (5.1.57) throws er开发者_运维技巧ror:

1366 - Incorrect integer value: '' for column 'id' at row 1

'' was being accepted without syntax error and did auto-increment the integer field to the next number on the original server (5.1.52). Any idea what could be the difference in the mysql server setup? It couldn't be the version difference, both are 5.1.xx?


Since id is auto_increment you should not mention it in your insert query :

INSERT INTO table (fld2 , fld3) VALUES ('v2', 'v3')

And besides you are inserting string in your id thus in case it was not auto_increment you would get the same error anyway.


Looks like the current server's default settings differ from the previous one. Have a look at MySQL's documentation regarding the strict mode settings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜