1

我有一张名为 event_log 的表,它的结构是这样的

CREATE TABLE `incident_log` (
`il_id` int NOT NULL auto_increment,    
`il_i_id` int default NULL,
`il_time_occured` datetime NOT NULL,
`il_status` varChar(255) NOT NULL default 'OPEN',       
`il_prevstate` varChar(255),        
`il_trigger` varchar(255),          
`il_current_state` int NOT NULL default 0, 
`il_prev_state` int NOT NULL default 0, 
`il_current_trigger` int NOT NULL default 0,                    
`il_prev_trigger` int NOT NULL default 0,
`il_pol_as_status` mediumblob,  
`il_obj_id` int,        
`il_occuredCount` int default 0,
`il_reportedOccuredCount` int default 0, 
`il_reportedCount` int default 0,   
`il_cascadeReportedTime` bigint default 0, 
`il_obj1` text,     
`il_obj2` text,     
`il_obj3` text,     
`il_itype` enum('CRITICAL','EVENT') NOT NULL default 'CRITICAL',
`il_usrNotifyStatus` enum('NEW','NOTIFIED','NOT_NOTIFIED') NOT NULL default 'NEW', 
`il_rootcause_il_id` int NOT NULL DEFAULT 0,
`il_rootcause_info` text DEFAULT NULL,
`il_rootcause_i_objclass` enum('DATASET','COMPONENT','SERVICE','SERVER','BCS') default NULL, 
`il_rootcause_i_obj_id` int(11) default 0,
`il_acset_id` int default NULL, 
`il_intRes1` int, 
`il_intRes2` int, 
`il_intRes3` int, 
`il_intRes4` int, 
`il_varcharRes1` varchar(64), 
`il_varcharRes2` varchar(255) );

但是当插入以下数据时,它给了我一个错误

ERROR 1136 (21S01): Column count doesn't match value count at row 1
INSERT INTO incident_log  (il_i_id, il_time_occured, il_cascadeReportedTime,
                           il_occuredCount,il_obj_id, il_obj1, il_obj2, il_obj3,
                           il_status, il_rootcause_il_id, il_rootcause_info, 
                           il_rootcause_i_objclass, il_rootcause_i_obj_id, 
                           il_acset_id)  
                  VALUES  (1,'',0,0,12,'','','','OPEN',0,NULL,NULL,0,NULL);

请帮我解决这个问题..

4

1 回答 1

1

我在您的创建表语法中发现了一些更正

  1. 应在主键中定义自动增量列
  2. il_time_occured在约会时间。''通过错误不正确的字段插入(空值)时。

你的插入语句没有错

此查询工作正常。

INSERT INTO incident_log (il_i_id, il_time_occured, il_cascadeReportedTime, il_occuredCount,il_obj_id, il_obj1, il_obj2, il_obj3, il_status, il_rootcause_il_id, il_rootcause_info, il_rootcause_i_objclass, il_rootcause_i_obj_id, il_acset_id) VALUES (1,'2012-12-27 16:03:32',0,0,12,'','','','OPEN',0,NULL,NULL,0,NULL)

请参阅屏幕短: 在此处输入图像描述

请参阅 sqlfiddle 演示。

于 2012-12-27T10:42:17.853 回答