ragerdl ragerdl - 4 months ago 7
SQL Question

Oracle SQL: Change an already-existing relationship from mandatory to optional

Suppose I have a foreign key named

my_fk
that goes between two tables named
table_a
and
table_b
, where
table_a
is the "many" side and
table_b
contains the unique record that
table_a
is referencing. How would I go about changing an already-existing relationship from mandatory to optional? What SQL do I need to type?

Answer

If you want to make the relationship optional, you just need to allow nulls in the column from table_a that has a foreign key relationship to the table_b table.

alter table table_a modify fk_col_name null

Note: Replace fk_col_name by the actual column name.

Comments