Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oprW7-0002Ad-9P for pgsql-general@arkaria.postgresql.org; Tue, 01 Nov 2022 13:41:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oprW6-0001Ys-5v for pgsql-general@arkaria.postgresql.org; Tue, 01 Nov 2022 13:41:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oprW5-0001YI-P5 for pgsql-general@lists.postgresql.org; Tue, 01 Nov 2022 13:41:21 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oprW3-0004fn-1U for pgsql-general@lists.postgresql.org; Tue, 01 Nov 2022 13:41:21 +0000 Received: by mail-pj1-x102c.google.com with SMTP id k5so5653245pjo.5 for ; Tue, 01 Nov 2022 06:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=shWCsT62Sk3T+BgezT31Rw9fuzEuHrIR63bRdCi0gnI=; b=Vp3JS22ZSwLqUN/v26NUuTv8SdtU7DBiPXrow8AVN31Lcs1+TgI0Nry1STAcbU5OiX JgLP8wA/xcnSp2EKlHTGhOARhhGuBZMU1cei5F4uDBZwucv/RwoDJgIzd+px+F+e/U8z 2zJoX5vPmQtkdWZqk5D+4h5HP7UiHauHqS6yY35sKu+AnTSKlAl/o0zgHK/D/cG1vOaU TWpsdXWQi+5zJ0X5LdgDvdr02cIm0fo7uaWDyeZQJ0MoxKBpzTEzBJRWBv2kVFsgeW1l LjRmeQj6XBUJnoVHW1PeuR8jGQklZb4AdbmhmSMVZrxbn6oAxtLjjdTMVPDwdl3ezAP+ AAlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=shWCsT62Sk3T+BgezT31Rw9fuzEuHrIR63bRdCi0gnI=; b=z8Bs40iHwKlIdb0HJU3eHt6BXKG3g19yc9ApBPhJuIgs5JSQ0phV0wavi0/i591UmV /epwY+RTJksItHtEEVyY1hjtb8IX27jhdLdXn5cTDFLINkzLg9RjLpmGLFhLBSmUc6Ny nz2QYbxX5fKC1o4L1HB2phL+f5wdkIrb4+toLZP7sedPN+MBO92vA+GNcj1WBAXetSIb IZZ3mNHNXDOfrKv274CPhdLyZIgZRQY6tmY70SvI6rs2d4QG3AFEYFW9Hrq/UbxUY9sg ngaf7nAgz4L7Ai+3eZwCybiuep+TToghSi/7nmT8xFoLXN37VXLRjUpAPSZn++Y1owxb qm5A== X-Gm-Message-State: ACrzQf34eF+vevre3YDrJKvGqMa9hfwsFrjAdmNdCkxIcjZZueq3p4eP b6CGWnEvyqYJBzehRMBGvZdY63+D38E= X-Google-Smtp-Source: AMsMyM4+qE/Fn6ggqmroIEG6cxbYgV9PFbIvOGbh9IwQfjcPUayNLfJvygEeKt41Er8sxK9GFA20Yg== X-Received: by 2002:a17:90a:1a43:b0:20a:ea98:b962 with SMTP id 3-20020a17090a1a4300b0020aea98b962mr37672451pjl.118.1667310076296; Tue, 01 Nov 2022 06:41:16 -0700 (PDT) Received: from [10.128.56.136] ([155.98.131.0]) by smtp.gmail.com with ESMTPSA id k28-20020aa7999c000000b0056bfebfa6e4sm6460371pfh.190.2022.11.01.06.41.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Nov 2022 06:41:15 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------Bnhfl7UBMj8aTzw0BgAGisoG" Message-ID: Date: Tue, 1 Nov 2022 07:41:14 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: Delete a table automatic? Content-Language: en-CA To: pgsql-general@lists.postgresql.org References: From: Rob Sargent In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------Bnhfl7UBMj8aTzw0BgAGisoG Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 11/1/22 03:31, jian he wrote: > > > On Tue, Nov 1, 2022 at 2:33 PM 黄宁 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? > > > Your question seems not that specific. > You can use https://dbfiddle.uk/btGcOH30 to showcase your specific > problem/question. > > you can use DROP TABLE CASCADE. > DROP TABLE manual: > https://www.postgresql.org/docs/current/sql-droptable.html > Only If B has a foreign key reference to A > -- >  I recommend David Deutsch's <> > > Jian > > --------------Bnhfl7UBMj8aTzw0BgAGisoG Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 11/1/22 03:31, jian he wrote:


On Tue, Nov 1, 2022 at 2:33 PM 黄宁 <huangning0722@gmail.com> 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?

Your question seems not that specific.
You can use https://dbfiddle.uk/btGcOH30 to showcase your specific problem/question.

you can use DROP TABLE CASCADE.


Only If B has a foreign key reference to A
--
 I recommend David Deutsch's <<The Beginning of Infinity>>

  Jian



--------------Bnhfl7UBMj8aTzw0BgAGisoG--