Skip to main content
1 of 2

SQL - Query on table creation, referential integrity

Please let us know what does the below definition means on table creation.

CREATE TABLE A(w INT PRIMARY KEY);

CREATE TABLE B(x INT PRIMARY KEY REFERENCES A(w) ON SET NULL)

As per my understanding, there is a foreign key reference on attribute-B(x) with attribute-A(w) and B(x) will set to null when A(w) is deleted that reference to B(x). Will this not violate the primary key constraint on X, which cannot be NULL?

Thanks in advance -Phani