foreign key constraints and alter table

Started by John DeSoiabout 23 years ago2 messagesgeneral
Jump to latest
#1John DeSoi
jdesoi@planetc.com

If I'm reading the docs correctly, I should be able to write:

ALTER TABLE mytable ADD ptr INT4 REFERENCES othertable ON DELETE SET NULL

but when I look in pg_constraint table (pg 7.3) I don't see any kind
of foreign key constraint.

BTW, are the PDF versions of the 7.3 Docs? I only see 7.2 on the web site.

Thanks!

John DeSoi, Ph.D.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: John DeSoi (#1)
Re: foreign key constraints and alter table

John DeSoi <jdesoi@planetc.com> writes:

If I'm reading the docs correctly, I should be able to write:
ALTER TABLE mytable ADD ptr INT4 REFERENCES othertable ON DELETE SET NULL
but when I look in pg_constraint table (pg 7.3) I don't see any kind
of foreign key constraint.

ALTER TABLE ADD COLUMN is dropping foreign key clauses in 7.3-7.3.2 :-(
See patch posted about four days ago. In the meantime, add the foreign
key separately.

regards, tom lane