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 |
Thread: | |
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 | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2009-07-15 18:15:24 | Re: savepoints in 8.3.7 or whatever... |
Previous Message | Mike Toews | 2009-07-15 18:13:55 | Re: PL/Python debugging - line numbers |