Обсуждение: Renaming a database

Поиск
Список
Период
Сортировка

Renaming a database

От
Florian Weimer
Дата:
Is there a way to rename an existing database, short of dumping and
restoring it?

--
Florian Weimer                       Weimer@CERT.Uni-Stuttgart.DE
University of Stuttgart           http://CERT.Uni-Stuttgart.DE/people/fw/
RUS-CERT                          fax +49-711-685-5898

Re: Renaming a database

От
Tom Lane
Дата:
Florian Weimer <Weimer@CERT.Uni-Stuttgart.DE> writes:
> Is there a way to rename an existing database, short of dumping and
> restoring it?

In 7.1 or later a quick UPDATE on pg_database.datname should do it,
I believe.

It might be a bad idea to do it while there are any connections to
the target database --- I know that backends remember the name of the
DB they are connected to, but I forget whether it's actually used for
anything significant.

Also, vacuuming pg_database after committing the UPDATE might be
necessary, depending on just which version you are running.

            regards, tom lane