Re: change database

Поиск
Список
Период
Сортировка
От Jeff Davis
Тема Re: change database
Дата
Msg-id 1247681637.5902.70.camel@monkey-cat.sm.truviso.com
обсуждение исходный текст
Ответ на change database  (Florian Chis <florian.chis@gmail.com>)
Список 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


В списке pgsql-general по дате отправления:

Предыдущее
От: John R Pierce
Дата:
Сообщение: savepoints in 8.3.7 or whatever...
Следующее
От: Mike Toews
Дата:
Сообщение: Re: PL/Python debugging - line numbers