Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否允许在mysql整数列中使用引号?_Mysql_Mysql Error 1067 - Fatal编程技术网

是否允许在mysql整数列中使用引号?

是否允许在mysql整数列中使用引号?,mysql,mysql-error-1067,Mysql,Mysql Error 1067,考虑表1的表模式: id: int country_id: int description: varchar(50) id:int 国家/地区id:int 说明:varchar(50) 以及查询: INSERT INTO table1(id, country_id, description) VALUES (1, '20', 'Test Desc'); 在表1(id、国家/地区id、说明)中插入值(1,'20','Test Desc'); 这将在MySQL 4x下工作,但在MySQL 5x下将失

考虑表1的表模式:

id: int country_id: int description: varchar(50) id:int 国家/地区id:int 说明:varchar(50) 以及查询:

INSERT INTO table1(id, country_id, description) VALUES (1, '20', 'Test Desc'); 在表1(id、国家/地区id、说明)中插入值(1,'20','Test Desc'); 这将在MySQL 4x下工作,但在MySQL 5x下将失败(错误1067(42000):无效的默认值…)

我知道发生这种情况的原因-country_id是int,因此不应该被引用。是否有一个mysql开关在5x下的某个地方使其行为类似4x,这样查询就不会失败

我继承了一个使用类似查询的应用程序,我正在寻找一个快速修复方法,直到我能找到时间修复所有查询


谢谢

20没有问题。MySql(5.x)还将“20”强制转换为20,并且=>这是一个有效的插入

您确定您的自动递增字段不是也有默认值吗?他们在5中删除了该字段。或者您是否使用“”作为int的默认值?您现在必须使用0或NULL。很抱歉,仔细查看后,它看起来像是int字段的查询插入“”int列的默认值为0