Thread: SET database TO ...?

SET database TO ...?

From
ow
Date:
Hi,

Suppose, one server/postmaster is running several databases. Is there something
like "SET database TO whatever" (and I mean *database* not schema). I need this
to ensure that a script runs only against db for which it was desinged.

Thanks







__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


Re: SET database TO ...?

From
Achilleus Mantzios
Date:
On Mon, 15 Sep 2003, ow wrote:

> Hi,
> 
> Suppose, one server/postmaster is running several databases. Is there something
> like "SET database TO whatever" (and I mean *database* not schema). I need this
> to ensure that a script runs only against db for which it was desinged.

[postgres@smadev ~]% psql
Welcome to psql 7.3.4, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms      \h for help with SQL commands      \? for help on internal slash commands
    \g or terminate with semicolon to execute query      \q to quit
 

dynacom=# \c bab
You are now connected to database bab.
bab=# 
bab=# 
bab=# \c dynacom
You are now connected to database dynacom.
dynacom=# \q
[postgres@smadev ~]%

> 
> Thanks
> 
> 
> 
> 
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
> 

-- 
==================================================================
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel:    +30-210-8981112
fax:    +30-210-8981877
email:  achill at matrix dot gatewaynet dot com       mantzios at softlab dot ece dot ntua dot gr



Re: SET database TO ...?

From
"A.Bhuvaneswaran"
Date:
> Suppose, one server/postmaster is running several databases. Is there
> something like "SET database TO whatever" (and I mean *database* not
> schema). I need this to ensure that a script runs only against db for
> which it was desinged.

You can use PG* environment variables if you wish to write seperate script
for each databases.

regards,
bhuvaneswaran



Re: SET database TO ...?

From
ow
Date:
--- Achilleus Mantzios <achill@matrix.gatewaynet.com> wrote:
[...]
> dynacom=# \c bab
> You are now connected to database bab.
> bab=# 

I'm actually looking for a way to set database from a *script*, not psql
console, if this is possible (similar to "SET search_path TO whatever;").

Any ideas? Thanks









__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


Re: SET database TO ...?

From
Tom Lane
Date:
ow <oneway_111@yahoo.com> writes:
> --- Achilleus Mantzios <achill@matrix.gatewaynet.com> wrote:
>> dynacom=# \c bab
>> You are now connected to database bab.

> I'm actually looking for a way to set database from a *script*, not psql
> console, if this is possible (similar to "SET search_path TO whatever;").

If the script is being fed to psql, it can use \c ...
        regards, tom lane