Re: Delete a table automatic?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: 黄宁 <huangning0722(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Delete a table automatic?
Date: 2022-11-01 15:23:18
Message-ID: 1181453.1667316198@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2022-11-01 16:05:30 Re: Autovacuum on Partitioned Tables
Previous Message Ryan Ruenroeng 2022-11-01 15:11:36 Re: Autovacuum on Partitioned Tables