Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Mysql Dump File from INSERT to INSERT IGNORE

I have a huge dump file about 40G in size, and I need to dump that back into the database since there are some records are missing after a recovery. Is there any easy way I can covert the INSERT into INSERT IGNORE in the dump file to avoid duplicate entries errors? loading the file to a text editor seems a no go to me. thank you very much in advance

like image 801
Gäng Tian Avatar asked Jan 09 '12 18:01

Gäng Tian


People also ask

Can ignore be used with insert statement?

However, with the INSERT IGNORE statement, we can prevent such errors from popping up, especially when inserting entries in bulk and such errors can interrupt the flow of insertion. Instead, only a warning is generated. Upon insertion of NULL value where the column has a NOT NULL constraint.

What is insert ignore in MySQL?

The INSERT IGNORE command keeps the first set of the duplicated records and discards the remaining. The REPLACE command keeps the last set of duplicates and erases out any earlier ones. Another way to enforce uniqueness is to add a UNIQUE index rather than a PRIMARY KEY to a table.

Is insert ignore faster than insert?

Similar to deletes and replace into, with this scheme, “insert ignore” can be two orders of magnitude faster than insertions into a B-tree.

How do I Upsert in MySQL?

We can perform MySQL UPSERT operation mainly in three ways, which are as follows: UPSERT using INSERT IGNORE. UPSERT using REPLACE. UPSERT using INSERT ON DUPLICATE KEY UPDATE.


1 Answers

There is also a switch for mysqldump

--insert-ignore in mysqldump

like image 71
davydotcom Avatar answered Oct 12 '22 23:10

davydotcom