| From: | H <agents(at)meddatainc(dot)com> | 
|---|---|
| To: | PostgreSQL Users Mailing List <pgsql-general(at)lists(dot)postgresql(dot)org> | 
| Subject: | Re: Dropping all tables in a database | 
| Date: | 2023-08-08 00:59:29 | 
| Message-ID: | 1cbbb815-fd38-9cf6-86db-eeb57b229342@meddatainc.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
On 08/06/2023 09:24 PM, Christophe Pettus wrote:
>
>> On Aug 6, 2023, at 18:17, H <agents(at)meddatainc(dot)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 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Meera Nair | 2023-08-08 07:39:48 | PostgreSQL 14.8 - server fails to start even though all transaction logs with base backup are restored | 
| Previous Message | Ron | 2023-08-07 15:08:28 | Re: DB Server slow down & hang during Peak hours of Usage |