Search Postgresql Archives

Re: Dropping all tables in a database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 7, 2023 at 9:25 AM Christophe Pettus <xof@xxxxxxxxxxxx> wrote:
>
> > On Aug 6, 2023, at 18:17, H <agents@xxxxxxxxxxxxxx> 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.

The easiest solution it to simply rely on the \gexec meta-command on
psql (see https://www.postgresql.org/docs/current/app-psql.html) which
is exactly meant for that.






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux