Thread: Change the name of the database

Change the name of the database

From
Sylvain Brohée
Date:
Could somebody help me?
I'm trying to change the name of my psql database.
Does it exist any command to do this.

Thanks a lot for your help,

Sylvain Brohée
Free University of Brussels


Re: Change the name of the database

From
Chris Mair
Date:
> Could somebody help me?
> I'm trying to change the name of my psql database.
> Does it exist any command to do this.

Sure,
just issue this command:

  alter database old_db_name rename to new_db_name;

Bye,
Chris.




Re: [despammed] Change the name of the database

From
Andreas Kretschmer
Date:
am  17.01.2005, um 12:06:45 +0100 mailte Sylvain Brohée folgendes:
> Could somebody help me?
> I'm trying to change the name of my psql database.
> Does it exist any command to do this.

Create a dump, create the new db, and play the dump in the new db.


Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47212,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===

Re: Change the name of the database

From
Tom Lane
Date:
Chris Mair <list@1006.org> writes:
>> I'm trying to change the name of my psql database.
>> Does it exist any command to do this.

> just issue this command:
>   alter database old_db_name rename to new_db_name;

Note that this command exists only since PG 7.4.  In earlier releases,
you can fake it by executing a manual UPDATE on pg_database.  (Beware
that you need to do a CHECKPOINT afterware to be sure that newly
connecting backends will see the updated name.)

            regards, tom lane