Re: Rename database?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Rename database?
Date: 2000-05-30 15:27:19
Message-ID: 2253.959700439@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Philip Warner <pjw(at)rhyme(dot)com(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message The Hermit Hacker 2000-05-30 16:11:21 Re: Applying TOAST to CURRENT
Previous Message Tom Lane 2000-05-30 15:07:05 Re: Applying TOAST to CURRENT