Re: Dropping all tables in a database - Mailing list pgsql-general

From Christophe Pettus
Subject Re: Dropping all tables in a database
Date
Msg-id A645BF48-B811-425B-B924-0E7E094E7C46@thebuild.com
Whole thread Raw
In response to Dropping all tables in a database  (H <agents@meddatainc.com>)
Responses Re: Dropping all tables in a database
Re: Dropping all tables in a database
Re: Dropping all tables in a database
List pgsql-general

> On Aug 6, 2023, at 18:17, H <agents@meddatainc.com> 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
possiblebug? 

The first statement just generates a line of text output that contains the statement.  There's nothing in it that would
causethat 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
thatas a script. 


pgsql-general by date:

Previous
From: H
Date:
Subject: Dropping all tables in a database
Next
From: Julien Rouhaud
Date:
Subject: Re: Dropping all tables in a database