Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qTB4U-008gFJ-EQ for pgsql-general@arkaria.postgresql.org; Tue, 08 Aug 2023 00:59:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qTB4S-00CgVe-Fp for pgsql-general@arkaria.postgresql.org; Tue, 08 Aug 2023 00:59:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qTB4S-00CgVV-18 for pgsql-general@lists.postgresql.org; Tue, 08 Aug 2023 00:59:36 +0000 Received: from mout.perfora.net ([74.208.4.197]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qTB4O-0017TT-Oi for pgsql-general@lists.postgresql.org; Tue, 08 Aug 2023 00:59:34 +0000 Received: from [192.168.1.17] ([72.94.51.172]) by mrelay.perfora.net (mreueus002 [74.208.5.2]) with ESMTPSA (Nemesis) id 0M4oTz-1pavr52gcH-00yylV for ; Tue, 08 Aug 2023 02:59:30 +0200 Subject: Re: Dropping all tables in a database References: To: PostgreSQL Users Mailing List From: H Message-ID: <1cbbb815-fd38-9cf6-86db-eeb57b229342@meddatainc.com> Date: Mon, 7 Aug 2023 20:59:29 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Provags-ID: V03:K1:6M3ABMLgqTwdjI0R5hgbKrLY/LDEQ7wPxAZp+Gl14QN3djaAATH r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5snN7LDI02F13egfAH3xDL3PRIeDXZrqr5/lOLuyHhKS rrFipCjs3cSJvCQ== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 08/06/2023 09:24 PM, Christophe Pettus wrote: > >> On Aug 6, 2023, at 18:17, H wrote: >> >> Is there some setting I have to change in the database to have the first SQL statement to work or have I run into a possible bug? > The first statement just generates a line of text output that contains the statement. There's nothing in it that would cause that statement to be executed. > > If you want to create a statement dynamically and then execute it, you can do that with pl/pgSQL: > > https://www.postgresql.org/docs/current/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN > > Otherwise, the solution is to do as you did: write the output to a file, trim out any extraneous lines, and then use that as a script. Oops, you are right, thank you. I worked around it by making sure the database to be restored is saved using the options --clean, --if-exists and --no-owner which solve my problem.