200k views
2 votes
You are loading data into a table. Which command can you use to make sure that all data is inserted and duplicated rows are discarded?

a) INSERT IGNORE
b) INSERT REPLACE
c) INSERT SKIP DUPLICATES
d) INSERT OVERWRITE DUPLICATES

User Dudeman
by
8.3k points

1 Answer

4 votes

Final answer:

The correct command for inserting data into a table and discarding duplicates is 'INSERT IGNORE'. This command skips duplicates without errors but does not provide details on ignored rows.

Step-by-step explanation:

When loading data into a table and ensuring that all data is inserted while discarding duplicate rows, the correct command to use is a) INSERT IGNORE. This command enables the system to ignore rows that would cause a duplicate entry for the columns that are constrained by UNIQUE indexes. If a duplicate row is detected, it is skipped without causing an error, and the rest of the records are inserted.

It's important to note that this command should be used cautiously because while it prevents errors from halting the insertion of data, it does not provide details on which rows were duplicated and ignored. In cases where detailed information on duplicates is necessary or where the handling of duplicates requires customization, other SQL strategies or functions might be more appropriate.

User Evgeniy Zaykov
by
8.4k points