Mysql插入查询“列数与值计数不匹配”,其中列和值都相等
表格结构:
表:角色
列:
ID int(11) AI PK
NAME varchar(25)
LEVEL varchar(1)
DESCRIPTION varchar(200)
CREATED_DATE datetime
CREATED_BY varchar(32)
MODIFIED_DATE datetime
MODIFIED_BY varchar(32)
我的插入声明是:
INSERT INTO `role` VALUES
(1,'user','T','Default role for all user','2016-09-19 08:22:34','admin','2016-09-19 08:22:34','admin'),
(2,'admin','T','System admin','2016-09-19 08:22:34','admin','2016-09-19 08:22:34','admin'),
(3,'super','T','Super Admin','2016-09-19 08:22:34','admin','2016-09-19 08:22:34','admin'),
(4,'host_user','H','Test','2016-09-19 08:22:34','admin','2016-09-19 08:22:34','admin'),
(5,'host_admin','H','Demo','2016-09-19 08:22:34','admin','2016-09-19 08:22:34','admin'),
(6,'host_super','H','again Test','2016-09-19 08:22:34','admin','2016-09-19 08:22:34','admin');
答案 0 :(得分:0)
您已指定ID AS AI(自动增量)主键。当您指定不需要在插入值中传递主键时。 尝试删除它们:
INSERT INTO `role` VALUES
('user','T','Default role for all user','2016-09-19 08:22:34','admin','2016-09-19 08:22:34','admin'),
('admin','T','System admin','2016-09-19 08:22:34','admin','2016-09-19 08:22:34','admin'),
('super','T','Super Admin','2016-09-19 08:22:34','admin','2016-09-19 08:22:34','admin'),
('host_user','H','Test','2016-09-19 08:22:34','admin','2016-09-19 08:22:34','admin'),
('host_admin','H','Demo','2016-09-19 08:22:34','admin','2016-09-19 08:22:34','admin'),
('host_super','H','again Test','2016-09-19 08:22:34','admin','2016-09-19 08:22:34','admin');