Re: [PG9.1] CTE usage - Mailing list pgsql-general

From Adrian Klaver
Subject Re: [PG9.1] CTE usage
Date
Msg-id 52370CB6.8020001@gmail.com
Whole thread Raw
In response to Re: [PG9.1] CTE usage  (Ladislav Lenart <lenartlad@volny.cz>)
Responses Re: [PG9.1] CTE usage  (Ladislav Lenart <lenartlad@volny.cz>)
List pgsql-general
On 09/16/2013 04:57 AM, Ladislav Lenart wrote:
> On 16.9.2013 13:26, Alban Hertroys wrote:

>>
>> Wouldn't it be much easier to define an FK constraint with ON DELETE CASCADE?
>> With that, you only need to worry about which rows you delete from the
>> parent table and dependant children will be removed automatically.
>
>
> Hello.
>
> I don't quite follow. Having item.item_type1_id FK with ON DELETE CASCADE would
> delete ITEM (the parent) when ITEM_TYPE1 (the child) is deleted. You suggests
> the opposite direction.

http://www.postgresql.org/docs/9.3/interactive/sql-createtable.html

"..In addition, when the data in the referenced columns is changed,
certain actions are performed on the data in this table's columns. The
ON DELETE clause specifies the action to perform when a referenced row
in the referenced table is being deleted. .."

"..CASCADE
Delete any rows referencing the deleted row, or update the values of the
referencing column(s) to the new values of the referenced columns,
respectively.
.."




--
Adrian Klaver
adrian.klaver@gmail.com


pgsql-general by date:

Previous
From: Ladislav Lenart
Date:
Subject: Re: [PG9.1] CTE usage
Next
From: Ladislav Lenart
Date:
Subject: Re: [PG9.1] CTE usage