Questenaتمرینی که نشان می‌دهد بعد چه چیزی را مرور کنید
سؤال 22

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

  1. The second insert fails with a unique violation
  2. Both rows are storedپاسخ درست
  3. The CREATE TABLE fails, because a UNIQUE column must also be NOT NULL
  4. The second insert is accepted but silently discarded

توضیح

By default two null values are not considered equal for uniqueness, so a UNIQUE column can hold any number of null rows. This is why a nullable UNIQUE column is not a safe way to enforce at most one row per entity, and why this default is worth stating explicitly in a schema.

ادامهٔ این آزمون

شروع تمرین
سؤال 22: In PostgreSQL 18, a table is created as CREATE TABLE c1 (x… · SQL: NULL, Joins and Aggregates · Questena