开发者

Mysql multiple insert statement not adding all records

I'm inserting a max of 3000 records and for this I just wrote a single query like

insert into p_code (id_user_staff,user_id,postalcode,dropDownGroup) 
values 
(187,51,'AB10',1), 
(187,51,'AB11',1), 
(187,51,'AB12',1), 
(187,51,'AB13',1), 
(187,51,'AB14',1), 
(187,51,'AB15',1), 
(187,51,'AB16',1), 
(187,51,'AB21',1), .........3000

This seems to be working fine, but it's not adding all records开发者_如何学编程, many of them are missed. I've also tried the same with each single query in for loop but this also is not adding all records.


I've also tried the same with each single query in for loop but this also is not adding all records.

Obviously the insert statement is fine then.
There is some constraint on the table that is preventing some values from being inserted.

This is either a unique or primary key. On one or more of the fields:
id_user_staff, user_id, dropDownGroup

Or a foreign key constaint that is not met on an insert.

Or a trigger that fires before the insert and that generates an error, thereby preventing the insert from being finalized.

If you do the big insert statement, you can use:

SHOW ERRORS; 

Afterwards that will give you the exact error(s) which is stopping the insert(s).

See: http://dev.mysql.com/doc/refman/5.0/en/show-warnings.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜