Multiple choice technology databases

If an UNIQUE KEY constraint on DATE column is created, will it accept the rows that are inserted with SYSDATE?

  1. will

  2. won't

  3. sometimes possible

  4. None of the above

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

A UNIQUE constraint prevents duplicate values in the column. If multiple rows are inserted with SYSDATE, they will have identical date-time values (down to the second) when inserted in rapid succession, causing constraint violations. Even if inserted at different times, the constraint will reject any duplicates, so it won't reliably accept all SYSDATE inserts.

AI explanation

SYSDATE is evaluated once per SQL statement in Oracle (not once per row), so a multi-row insert (e.g. an INSERT ... SELECT) that stamps every row with SYSDATE gives all of those rows the identical timestamp value. If the DATE column also carries a UNIQUE constraint, that batch of identical values violates uniqueness and the insert is rejected, which is why such rows generally won't be accepted.