Re: Creating DB programmatically?

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Creating DB programmatically?
Дата
Msg-id ivh02f$fot$1@dough.gmane.org
обсуждение исходный текст
Ответ на Creating DB programmatically?  (Roy's Email <rmw256@hotmail.com>)
Список pgsql-novice
Roy's Email, 12.07.2011 01:40:
> I would like to create my DB programmatically. I.e. If the DB does
> not already exist, I would like to be able to create (and populate)
> it from within my application. Is there some way to do this?
> Everything I see seems to require connecting to an existing DB before
> you can do anything.
>

Connect to one of the template databases (template0, template1) from within your program (those databases are always
there).
Then you have a valid connection through which you can execute the CREATE DATABASE statement.

You can also run a "SELECT datname FROM pg_database" using that connection to test if your database is already there.

Thomas



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

Предыдущее
От: Roy's Email
Дата:
Сообщение: Re: Creating DB programmatically?
Следующее
От: Michael Wood
Дата:
Сообщение: Re: Creating DB programmatically?