From: Tom Lane <tgl@sss.pgh.pa.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: 黄宁 <huangning0722@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Delete a table automatic?
Date: Tue, 01 Nov 2022 11:23:18 -0400
Message-ID: <1181453.1667316198@sss.pgh.pa.us> (raw)
In-Reply-To: <e7aaa4f0-0836-29da-974c-b24fa92e1be7@aklaver.com>
References: <CAKgrFs-PWb3O+aR==f1YYi+ehaBVyuAvy6H3dqwR3NAq9qeGqA@mail.gmail.com>
<e7aaa4f0-0836-29da-974c-b24fa92e1be7@aklaver.com>
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 10/31/22 18:44, 黄宁 wrote:
>> I now have two tables named A and B. Table B is calculated based on the
>> data of table A. I wonder if table B can be automatically deleted when
>> table A is deleted?
> The only thing I can think of is a sql_drop event trigger:
I wonder whether the OP's purposes wouldn't be better served by
making B a view or materialized view, instead of a separate table.
Then the cascaded-drop behavior would be automatic.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, adrian.klaver@aklaver.com, huangning0722@gmail.com
Subject: Re: Delete a table automatic?
In-Reply-To: <1181453.1667316198@sss.pgh.pa.us>
References: <CAKgrFs-PWb3O+aR==f1YYi+ehaBVyuAvy6H3dqwR3NAq9qeGqA@mail.gmail.com> <e7aaa4f0-0836-29da-974c-b24fa92e1be7@aklaver.com> <1181453.1667316198@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox