Multiple choice technology databases

CREATE SET TABLE A (A Integer, B Integer) Unique Primary Index (A) INSERT INTO Table A (1, 2) INSERT INTO Table A (1, 1) UPDATE Table A SET b = b + 1 WHERE b = 1. Which statement is correct?

  1. Both the INSERTs and the UPDATE fails.

  2. The INSERTs work, but the UPDATE fails

  3. Only the first INSERT works.

  4. Only the second INSERT works

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

The first INSERT succeeds because no rows exist. The second INSERT fails because it violates the Unique Primary Index on column A - row (1,2) already exists with A=1. The UPDATE would affect 0 rows since the second INSERT failed.