Re: Rename database? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Rename database?
Date
Msg-id 2253.959700439@sss.pgh.pa.us
Whole thread Raw
In response to Rename database?  (Philip Warner <pjw@rhyme.com.au>)
List pgsql-hackers
Philip Warner <pjw@rhyme.com.au> writes:
> I have looked (briefly) through the general, sql, and hackers archives,and
> could not find anything the addressed the ability to rename a database.

Nope, we haven't got it.

As long as there are no backends running in the DB, I think it'd just
be a matter of renaming the subdirectory of data/base/ and updating the
pg_database row with the new name.  You could do that manually if you
are comfortable with assuming that no one is connected to the DB while
you do it.

> 1) is is there a place for a pg_rename utility? 

It could not be a standalone utility because it'd have no way to
interlock against running backends.  It'd have to be implemented as
an SQL statement and use the same interlock method that DROP DATABASE
does.

> 2) would it be a difficult thing to write?

Probably not too tough if you used DROP DATABASE as a model.

Bear in mind though that the whole issue might go away, depending on
what happens with the tablespace/schema/physical-file-name-conventions
discussions.  Might want to see how that plays out before expending much
work on it.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Applying TOAST to CURRENT
Next
From: The Hermit Hacker
Date:
Subject: Re: Applying TOAST to CURRENT