K
K
Kolya2022-01-14 10:00:33
MySQL
Kolya, 2022-01-14 10:00:33

What are the limitations of INSERT IGNORE for partitioned tables?

Hello!
Duplicate data should be ignored. I will do INSERT IGNORE
help me understand the MySQL documentation.

When INSERT IGNORE is used, the insert operation fails silently for rows containing the unmatched value, but inserts rows that are matched.

I can't really understand this sentence. What threatens IGNORE for partitioned tables?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Akina, 2022-01-14
Pechenyushkin @shnegs

INSERT INTO may result in an error. For whatever reason. In this case, the insertion process is interrupted, and all changes already made to the tables are rolled back.
INSERT IGNORE converts an error to a warning. At the same time, the query execution continues, and the record, the attempt to insert which led to an error, is not inserted.
Comment. Duplication is not the only event that can cause an error. There may be a bunch of other reasons (CHECK constraint, SIGNAL from a trigger, foreign key violation, etc.). Moreover, not all types of errors are recoverable and can be ignored / converted into a warning. If the error is unrecoverable (as a rule, these are system or external errors), the request is aborted by error and rolled back in the usual way.
Remark 2.All of the above has nothing to do with partitioning. Except when the field value does not match the range for any of the sections. In this case, IGNORE works normally - the error is converted into a warning, the problem record is not inserted.

Duplicate data should be ignored. I will do INSERT IGNORE

In addition to INSERT IGNORE INTO, there are two more types of queries that handle the data duplication error - these are INSERT .. ON DUPLICATE KEY UPDATE and REPLACE INTO. Study them - perhaps one of them is better suited for your particular task. However, REPLACE does not support the IGNORE modifier and cannot ignore other errors.

D
Dmitry Roo, 2022-01-14
@xez

INSERT IGNORE will simply not throw an error on insertion (if possible).
The problem with data duplication is solved by constraints.
All.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question