From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Daulat Ram <Daulat.Ram@exponential.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: How to execute .sql file inside a postgres schema
Date: Mon, 29 Apr 2019 12:16:13 -0700
Message-ID: <3f1fa598-7d03-0577-fb6a-a6dde52f81de@aklaver.com> (raw)
In-Reply-To: <BL0PR01MB5187F12FAA0158DFE4CDDEDA9B390@BL0PR01MB5187.prod.exchangelabs.com>
References: <BL0PR01MB5187F12FAA0158DFE4CDDEDA9B390@BL0PR01MB5187.prod.exchangelabs.com>
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.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, Daulat.Ram@exponential.com
Subject: Re: How to execute .sql file inside a postgres schema
In-Reply-To: <3f1fa598-7d03-0577-fb6a-a6dde52f81de@aklaver.com>
References: <BL0PR01MB5187F12FAA0158DFE4CDDEDA9B390@BL0PR01MB5187.prod.exchangelabs.com> <3f1fa598-7d03-0577-fb6a-a6dde52f81de@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox