Re: Is renaming a database easy or dangerous

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
Cc: Hadley Willan <hadley(dot)willan(at)deeperdesign(dot)co(dot)nz>, Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Is renaming a database easy or dangerous
Date: 2003-03-07 03:58:00
Message-ID: 200303070358.h273w0X18299@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

scott.marlowe wrote:
> On 27 Feb 2003, Hadley Willan wrote:
>
> > Hello,
> > 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?
>
> The way I do it is:
>
> # createdb newdb
> # pg_dump olddb|psql -e newdb
> ... check to make sure it's all there working, then...
> # dropdb olddb

The coolest way I have seen it done is to do CREATE DATABASE with
TEMPLATE old_dbname, then drop the old database.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-03-07 04:38:25 Re: foreign key constraint across databases
Previous Message Rich Shepard 2003-03-07 03:10:14 Upgrading to 7.3.2