Re: Is renaming a database easy or dangerous

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hadley Willan <hadley(dot)willan(at)deeperdesign(dot)co(dot)nz>
Cc: Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Is renaming a database easy or dangerous
Date: 2003-02-26 23:47:55
Message-ID: 7379.1046303275@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hadley Willan <hadley(dot)willan(at)deeperdesign(dot)co(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dennis Gearon 2003-02-27 00:05:53 Re: Still intrigued... (was: Socket command type e unknown)
Previous Message Tom Lane 2003-02-26 23:34:32 Re: Still intrigued... (was: Socket command type e unknown)