🎴 Flashcard Mode
SQL, PL-SQL, and Java Programming Quiz
Card1 / 20
Mastered0
Review0
QuestionClick to flip
Which of the following queries can be used to delete duplicate records from a table -
AnswerClick to flip back
A
delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name);
💡 Explanation:
To delete duplicates, you keep one instance (usually the one with max rowid) and delete the rest. Option A correctly identifies rows where rowid is NOT IN the maximum rowid for each duplicate group. Options B and C would keep the wrong records or delete all records. Option D is incorrect because selecting rowid directly without an aggregate in the GROUP BY clause won't identify the max per group.