Re: deleting the master but not the detail

From: "Webb Sprague" <webb(dot)sprague(at)gmail(dot)com>
To: "Ismael (dot)(dot)(dot)(dot)" <ismaelpsp(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: deleting the master but not the detail
Date: 2008-07-17 18:50:21
Message-ID: b11ea23c0807171150x79452acawe969a2bfe0c9bde8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>>> hi
>>>> I have one of those master-detail relationships here and I need to be able
>>>> to delete the master but leave the details untouched

when you create the table with an FK constraint, use the ON DELETE SET
NULL option, or SET DEFAULT. And read the docs on "CREATE TABLE":

http://www.postgresql.org/docs/8.3/static/sql-createtable.html

>>>
>>> Then remove the referential integrity constraint, since it's obviously
>>> incompatible with your business requirements.

Wrong. See above. Unless I misunderstand, then I apologize for the noise....

In response to

Browse pgsql-general by date

  From Date Subject
Next Message salman 2008-07-17 18:50:35 Re: TODO list and "hyphen"
Previous Message Tom Lane 2008-07-17 18:43:15 Re: [HACKERS] postmaster.pid not visible