Multiple choice technology databases

Given that tables T1 and T2 contain the following rows : Table T1 : C1 C2 (5 4) (5 2) (5 5) Table T2 : C1 C2 (5 1) (5 2) (5 3) Which of the following queries will return only those rows that exists in T1 and not in T2 ?

  1. Select * from T1 minus select * from T2

  2. Select * from T1 except select * from T2

  3. Select * from T1 union except select * from T2

  4. Select * from T1 not exists select * from T2

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

To find rows that exist in T1 but not in T2, you need a set difference operation. In SQL, the EXCEPT operator returns all rows from the first query that are not present in the second query. Option B is correct: SELECT * FROM T1 EXCEPT SELECT * FROM T2 will return only the rows from T1 that don't have matching rows in T2. Option A uses MINUS which is Oracle syntax, not DB2. Option C is invalid syntax - UNION and EXCEPT cannot be combined that way. Option D is incorrect because NOT EXISTS requires a correlated subquery, not a standalone SELECT.