Multiple choice technology databases

How do I eliminate duplicate rows in an Oracle database?

  1. DELETE FROM table_name WHERE ROWID IN (SELECT MAX (ROWID) FROM table_name GROUP BY duplicate_values_field_name);

  2. DELETE FROM table_name WHERE ROWID NOT IN (SELECT MAX (ROWID) FROM table_name GROUP BY duplicate_values_field_name);

  3. DELETE FROM table_name WHERE ROWID IN (SELECT MIN (ROWID) FROM table_name GROUP BY duplicate_values_field_name);

  4. DELETE FROM table_name WHERE ROWID IN (SELECT AVG (ROWID) FROM table_name GROUP BY duplicate_values_field_name);

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This query keeps exactly one row for each set of duplicates (the one with the maximum ROWID) and deletes the rest. Grouping by the duplicate fields identifies duplicate groups, and selecting NOT IN MAX(ROWID) safely deletes all redundant records except the single unique representative record.