nerdexam
CompTIA

DS0-001 · Question #19

A database administrator is migrating the information in a legacy table to a newer table. Both tables contain the same columns, and some of the data may overlap. Which of the following SQL commands…

The correct answer is A. UNION. The UNION operator (option A) combines the result sets of two SELECT statements and automatically removes duplicate rows, making it ideal for merging two tables that share some overlapping records. Running INSERT INTO new_table SELECT FROM new_table UNION SELECT FROM…

Database Fundamentals

Question

A database administrator is migrating the information in a legacy table to a newer table. Both tables contain the same columns, and some of the data may overlap. Which of the following SQL commands should the administrator use to ensure that records from the two tables are not duplicated?

Options

  • AUNION
  • BJOIN
  • CINTERSECT
  • DCROSS JOIN

How the community answered

(16 responses)
  • A
    88% (14)
  • B
    6% (1)
  • D
    6% (1)

Explanation

The UNION operator (option A) combines the result sets of two SELECT statements and automatically removes duplicate rows, making it ideal for merging two tables that share some overlapping records. Running INSERT INTO new_table SELECT * FROM new_table UNION SELECT * FROM legacy_table will insert all unique records from both tables. UNION ALL would keep duplicates, but plain UNION deduplicates. Option B (JOIN) combines rows from two tables based on a related column - it does not merge records and does not remove duplicates across the two tables. Option C (INTERSECT) returns only rows that exist in BOTH tables - the opposite of what is needed. Option D (CROSS JOIN) produces a Cartesian product (every row paired with every other row), which is incorrect here.

Topics

#SQL Commands#Set Operators#Data Migration#Duplicate Data Handling

Community Discussion

No community discussion yet for this question.

Full DS0-001 Practice