Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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

> 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

pgsql-hackers by date

Next:From: The Hermit HackerDate: 2000-05-30 16:11:21
Subject: Re: Applying TOAST to CURRENT
Previous:From: Tom LaneDate: 2000-05-30 15:07:05
Subject: Re: Applying TOAST to CURRENT

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group