Re: change database

Lists: pgsql-general
From: Florian Chis <florian(dot)chis(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: change database
Date: 2009-07-15 08:36:34
Message-ID: 32f81f010907150136v424672a4m2db78b98fac13482@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi,

I'm working on a port from mysql to postgres. I have a function which
connect's to the database, checks for database existance and creates it
otherwise.
The last thing it does it executes "use my_database" (mysql stuff). Now I'm
trying to find something similar in postgres. I know that psql has \c but
that dosen't help me with jdbc. I also know that the easy solution out of
this is to close the connection and then open it again with /my_database in
the URL but I want to avoid this.

So what are my options?

With thanks,
Florian


From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Florian Chis <florian(dot)chis(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: change database
Date: 2009-07-15 18:13:57
Message-ID: 1247681637.5902.70.camel@monkey-cat.sm.truviso.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, 2009-07-15 at 11:36 +0300, Florian Chis wrote:
> I'm working on a port from mysql to postgres. I have a function which
> connect's to the database, checks for database existance and creates
> it otherwise.
> The last thing it does it executes "use my_database" (mysql stuff).
> Now I'm trying to find something similar in postgres. I know that psql
> has \c but that dosen't help me with jdbc. I also know that the easy
> solution out of this is to close the connection and then open it again
> with /my_database in the URL but I want to avoid this.
>
> So what are my options?

In PostgreSQL, a "schema" is similar to a "database" in MySQL -- both
are effectively namespaces (logical separation). You can switch
namespaces (schemas) in postgresql without reconnecting by simple set
commands, like: SET search_path = my_new_schema, public;

In PostgreSQL, a "database" is more of a physical separation, and your
connection is tied to a particular database. This is probably not what
you want.

More information here:
http://www.postgresql.org/docs/8.4/static/sql-createschema.html
http://www.postgresql.org/docs/8.4/static/sql-createdatabase.html

Regards,
Jeff Davis


From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: Florian Chis <florian(dot)chis(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: change database
Date: 2009-07-15 18:25:42
Message-ID: 20090715142542.0cb70887.wmoran@potentialtech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

In response to Florian Chis <florian(dot)chis(at)gmail(dot)com>:
>
> I'm working on a port from mysql to postgres. I have a function which
> connect's to the database, checks for database existance and creates it
> otherwise.
> The last thing it does it executes "use my_database" (mysql stuff). Now I'm
> trying to find something similar in postgres. I know that psql has \c but
> that dosen't help me with jdbc. I also know that the easy solution out of
> this is to close the connection and then open it again with /my_database in
> the URL but I want to avoid this.

Close the connection and reopen it. There's no equivalent.

--
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/


From: Florian Chis <florian(dot)chis(at)gmail(dot)com>
To: Bill Moran <wmoran(at)potentialtech(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: change database
Date: 2009-07-17 06:58:23
Message-ID: 32f81f010907162358q1a3907br7ea7383345d16fab@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Since there is no other way, I'll close it then reopen it again.
Thank you for your time.

Regards,
Florian Chis

2009/7/15 Bill Moran <wmoran(at)potentialtech(dot)com>

> In response to Florian Chis <florian(dot)chis(at)gmail(dot)com>:
> >
> > I'm working on a port from mysql to postgres. I have a function which
> > connect's to the database, checks for database existance and creates it
> > otherwise.
> > The last thing it does it executes "use my_database" (mysql stuff). Now
> I'm
> > trying to find something similar in postgres. I know that psql has \c but
> > that dosen't help me with jdbc. I also know that the easy solution out of
> > this is to close the connection and then open it again with /my_database
> in
> > the URL but I want to avoid this.
>
> Close the connection and reopen it. There's no equivalent.
>
> --
> Bill Moran
> http://www.potentialtech.com
> http://people.collaborativefusion.com/~wmoran/<http://people.collaborativefusion.com/%7Ewmoran/>
>


From: Michael Gould <mgould(at)intermodalsoftwaresolutions(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: uuid-ossp for PostGres 8.4 running on Windows
Date: 2009-07-18 14:30:18
Message-ID: 74c413bf5f6a5225bee15f7f02a8db9f@intermodalsoftwaresolutions.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Does anyone have a install or the proper files (not the source) to install
the uuid-ossp contrib files for 8.4?  The one thing that I think that
EnterpriseDB install is lacking in is the contrib modules that have been in
the previous postgres version installation.  Is this something that is going
to be added back into the EnterpriseDB installer?

At any rate my main concern now is to get the uuid-ossp install for 8.4 so
that I can use 8.4 for our new development.

 

Best Regards

--
Michael Gould, Managing Partner
Intermodal Software Solutions, LLC
904.226.0978
904.592.5250 fax


From: Sachin Srivastava <sachin(dot)srivastava(at)enterprisedb(dot)com>
To: Michael Gould <mgould(at)intermodalsoftwaresolutions(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: uuid-ossp for PostGres 8.4 running on Windows
Date: 2009-07-18 15:39:39
Message-ID: 4A61ECBB.8030600@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hello Michael,

In the EnterpriseDB installer, uuid-ossp contrib module is available but
not loaded/enabled by default. To enable uuid-ossp module simply run the
uuid-ossp.sql file ("share\contrib\uuid-ossp.sql").

This is something that i did:

psql.exe -U postgres -d postgres -f share\contrib\uuid-ossp.sql

Then from psql i fired the below query and got results,

SELECT uuid_generate_v3(uuid_ns_url(), 'http://www.postgresql.org');

Hope it helps.

On 07/18/2009 08:00 PM, Michael Gould wrote:
>
> Does anyone have a install or the proper files (not the source) to
> install the uuid-ossp contrib files for 8.4? The one thing that I
> think that EnterpriseDB install is lacking in is the contrib modules
> that have been in the previous postgres version installation. Is this
> something that is going to be added back into the EnterpriseDB installer?
>
> At any rate my main concern now is to get the uuid-ossp install for
> 8.4 so that I can use 8.4 for our new development.
>
> Best Regards
>
> ------------------------------------------------------------------------
> Michael Gould, Managing Partner
> Intermodal Software Solutions, LLC
> 904.226.0978
> 904.592.5250 fax

--
Regards,
Sachin Srivastava
www.enterprisedb.com


From: Michael Gould <mgould(at)intermodalsoftwaresolutions(dot)net>
To: Sachin Srivastava <sachin(dot)srivastava(at)enterprisedb(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: uuid-ossp for PostGres 8.4 running on Windows
Date: 2009-07-18 16:30:25
Message-ID: 4e656560171048442ddde9dd6f821388@intermodalsoftwaresolutions.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Thanks, that worked perfectly.

Best Regards

Michael Gould

 

"Sachin Srivastava" <sachin(dot)srivastava(at)enterprisedb(dot)com> wrote:
 

>Hello Michael,
>
>In the EnterpriseDB installer, uuid-ossp contrib module is available but
>not loaded/enabled by default. To enable uuid-ossp module simply run the
>uuid-ossp.sql file ("share\contrib\uuid-ossp.sql").
>
>This is something that i did:
>
>psql.exe -U postgres -d postgres -f share\contrib\uuid-ossp.sql
>
>Then from psql i fired the below query and got results,
></pre>
>
>SELECT uuid_generate_v3(uuid_ns_url(), '<a
>href="http://www.postgresql.org">http://www.postgresql.org</a>');
>
></pre>
>Hope it helps.
>
>
>
>On 07/18/2009 08:00 PM, Michael Gould wrote:
>>
>>Does anyone have a install or the proper files (not the source) to install
>>the uuid-ossp contrib files for 8.4?  The one thing that I think that
>>EnterpriseDB install is lacking in is the contrib modules that have been
in
>>the previous postgres version installation.  Is this something that is
>>going to be added back into the EnterpriseDB installer?
>>
>>
>>At any rate my main concern now is to get the uuid-ossp install for 8.4 so
>>that I can use 8.4 for our new development.
>>
>>
>> 
>>
>>
>>Best Regards
>>
>>
>>
>>--------------------------------
>>
>>Michael Gould, Managing Partner
>>Intermodal Software Solutions, LLC904.226.0978904.592.5250 fax
>
>
>
>--
>Regards,
>Sachin Srivastava
><a href="http://www.enterprisedb.com">www.enterprisedb.com</a>
></pre>
>