Can foreign key references contain NULL values in PostgreSQL?

For table 1, this INSERT statement will succeed. If you run it 100 times, it will succeed 100 times.

insert into referencing_table values (null);

The same INSERT statement will fail on table 2.

ERROR:  null value in column "indexing_table_id" violates not-null constraint
DETAIL:  Failing row contains (null).

Leave a Comment