Re: How to execute .sql file inside a postgres schema

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Daulat Ram <Daulat(dot)Ram(at)exponential(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: How to execute .sql file inside a postgres schema
Date: 2019-04-29 19:16:13
Message-ID: 3f1fa598-7d03-0577-fb6a-a6dde52f81de@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 4/29/19 7:02 AM, Daulat Ram wrote:
> Hello team,
>
> I have a database name “kbdb” that is having a schema “kb” and I want to
> execute the test.sql file inside this schema,
>
> Please help how we can do that.

You can do as Daniel suggested but be aware that it is equivalent to:

https://www.postgresql.org/docs/11/sql-set.html
SET search_path TO value

That means if you have objects in the script that are not schema
qualified and need to point to other schemas then things will fail. A
longer term solution would to schema qualify the objects in your script.
This is assuming that the script is not generic and is meant to 'float'
from schema to schema.

>
> Regards,
>
> Daulat
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Philippe Chenel 2019-04-30 02:19:35 RE: 9.6.9 Default configuration for a default installation but different with-krb-srvnam
Previous Message Stephen Frost 2019-04-29 17:35:10 Re: 9.6.9 Default configuration for a default installation but different with-krb-srvnam