使用INSERT和AUTO-INCREMENT列的SQL语句出错

run*_*day 1 mysql

INSERT INTO `configuration` VALUES ('', 'News Box Character Count', 'NEWS_BOX_CHAR_COUNT', '200', 'Set the number of characters (bytes) that you want to display in the news preview box.', 19, 99, NULL, '2004-09-07 12:00:00', NULL, NULL);
Run Code Online (Sandbox Code Playgroud)

我在phpMyAdmin中运行此命令,它显示

#1366 - Incorrect integer value: '' for column 'configuration_id' at row 1
Run Code Online (Sandbox Code Playgroud)

configuration_id 是一个自动增量字段,从1开始

Sha*_*ngh 5

而不是这个 INSERT INTO configuration VALUES ('', 'News Box Character Count',

传递NULLauto_increment或整数列的值,或者您不能在sql查询中包含该列.

INSERT INTO `configuration` VALUES (NULL, 'News Box Character Count', ...
Run Code Online (Sandbox Code Playgroud)

这是因为,mysql在严格模式下运行.

NULL当没有任何内容可以输入时,您可以使用所有整数列,也可以关闭MySql Strict模式.