Search Postgresql Archives

Modifying a foreign key constraint?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



What's the best way to modify a foreign key constraint?

I need to change a foreign key from ON DELETE NO ACTION to ON DELETE CASCADE. Should I just drop the constraint and re-add it? For example:

ALTER TABLE foo DROP CONSTRAINT foo_bar_id_fkey;

ALTER TABLE foo ADD FOREIGN KEY (foo_bar_id_fkey) REFERENCES bar(id) ON DELETE CASCADE;

Is there a more compact way to do this, perhaps with a single ALTER TABLE command?

Thanks!

		Marc


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux