Received: from tele-post-20.mail.demon.net (tele-post-20.mail.demon.net [194.217.242.20]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g1BGgJE14947 for ; Mon, 11 Feb 2002 11:42:20 -0500 (EST) (envelope-from olly@lfix.co.uk) Received: from lfix.demon.co.uk ([158.152.59.127] helo=linda.lfix.co.uk) by tele-post-20.mail.demon.net with esmtp (Exim 3.34 #1) id 16aJWe-0001Rs-0K; Mon, 11 Feb 2002 16:41:56 +0000 Received: from localhost ([127.0.0.1] helo=localhost.localdomain ident=olly) by linda.lfix.co.uk with esmtp (Exim 3.34 #1 (Debian)) id 16aJYG-0007Bt-00; Mon, 11 Feb 2002 16:43:36 +0000 Subject: Re: Re-nameing a database? From: Oliver Elphick To: Naomi Walker Cc: Chris Ruprecht , PostGreSQL Admin Group In-Reply-To: <4.2.2.20020211085032.00adcc00@ecint.ecinet.com> References: <4.2.2.20020211085032.00adcc00@ecint.ecinet.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Evolution/1.0.2 Date: 11 Feb 2002 16:43:34 +0000 Message-Id: <1013445816.12184.44.camel@linda> Mime-Version: 1.0 X-Archive-Number: 200202/116 X-Sequence-Number: 3275 On Mon, 2002-02-11 at 15:50, Naomi Walker wrote: > Not in postgres, unfortunately. I'd love to be wrong. > > At 04:26 PM 2/10/02 -0600, Chris Ruprecht wrote: > > >Hi all, > > > >is there an easy way to re-name a database? In 7.1.3, you can do it by updating the row in pg_database and then restarting the postmaster: $ psql template1 ... template1=# \l List of databases Database | Owner | Encoding -----------+----------+----------- junk | olly | SQL_ASCII ... template0 | postgres | SQL_ASCII template1 | postgres | SQL_ASCII (8 rows) template1=# update pg_database set datname = 'rubbish' where datname = 'junk'; UPDATE 1 template1=# \l List of databases Database | Owner | Encoding -----------+----------+----------- rubbish | olly | SQL_ASCII ... template0 | postgres | SQL_ASCII template1 | postgres | SQL_ASCII (8 rows) template1=# \c rubbish FATAL 1: Database "rubbish" does not exist in the system catalog. Previous connection kept template1=# \c junk FATAL 1: Database "junk", OID 44062648, has disappeared from pg_database Previous connection kept template1=# \q $ sudo /etc/init.d/postgresql restart Password: Restarting PostgreSQL database: postmaster Stopped /usr/lib/postgresql/bin/postmaster (pid 15397). Starting PostgreSQL postmaster. postmaster successfully started $ psql template1 ... template1=# \c rubbish You are now connected to database rubbish. rubbish=# \c junk FATAL 1: Database "junk" does not exist in the system catalog. Previous connection kept rubbish=# An alternative method would be to dump everything with pg_dumpall and then edit the dump to change the database name. -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C