QuestenaՎարժանք, որը ցույց է տալիս՝ ինչ կրկնել հաջորդիվ
Հարց 23

In PostgreSQL 18, a table is created as CREATE TABLE c2 (x int UNIQUE NULLS NOT DISTINCT); and two rows are then inserted, both with x set to NULL. What happens?

  1. The second insert is accepted but silently discarded
  2. Both rows are stored
  3. The second insert fails with a unique violationՃիշտ պատասխան
  4. The CREATE TABLE fails, because NULLS NOT DISTINCT is not valid PostgreSQL 18 syntax

Բացատրություն

NULLS NOT DISTINCT makes the constraint treat nulls as equal to one another, so the second null collides with the first and the insert is rejected. The default, which can be written explicitly as NULLS DISTINCT, does the opposite.

Շարունակեք այս թեստով

Սկսել վարժանքը
Հարց 23: In PostgreSQL 18, a table is created as CREATE TABLE c2 (x… · SQL: NULL, Joins and Aggregates · Questena