mysql - Bulk insert statement with unique constraint -


i writing php script need generate unique codes. these codes generated admin user, 100k @ time. have algorithm generates code, there slight chance duplicate mix - 0.001% chance still cause problem.

i looking run bulk insert statement:

insert coupons ( 'code' ) values ('code1'),('code2'),('code3'); 

this have 100k codes in it. want know if of them unique except lets code100 insert stop @ code or continue on rest of inserts , let me know warning.

if end failing @ first duplicate, can it? performance isn't big issue admin area , can spin process off until completed.

if there duplicate found in bulk insert, entire insert fail -- not after duplicate. if performance not issue , doesn't matter if lose of inserts, each insert statement individually. otherwise, update algorithm check duplicates when generates codes.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -