Re: Is renaming a database easy or dangerous

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Is renaming a database easy or dangerous
Дата
Msg-id 7379.1046303275@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Is renaming a database easy or dangerous  (Hadley Willan <hadley.willan@deeperdesign.co.nz>)
Список pgsql-general
Hadley Willan <hadley.willan@deeperdesign.co.nz> writes:
>    I'd like to rename one of my databases. Is it is simple as changing
> the datname field in the pg_databases table?
> If so, is it done through ALTER database or a SQL update?

There is no ALTER DATABASE command for this.  I believe that since 7.1
you can get away with an UPDATE on the pg_database row, with a couple of
caveats:

* It's unwise to do this while there are any backends connected to the
target database.  I'm not sure whether they'd get seriously confused
because their database changed name, but you don't want to find out the
hard way.

* You will have to issue a CHECKPOINT (or wait for one to occur
automatically) before the change will be visible to incoming new
connections.  A "vacuum pg_database" command before checkpointing might
be helpful as well, though I think it's probably not necessary in most
cases.

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Still intrigued... (was: Socket command type e unknown)
Следующее
От: Dennis Gearon
Дата:
Сообщение: Re: Still intrigued... (was: Socket command type e unknown)