pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedRe-nameing a database?
6+ messages / 4 participants
[nested] [flat]
* Re-nameing a database?
@ 2002-02-10 22:26 Chris Ruprecht <chrup999@yahoo.com>
2002-02-11 00:07 ` Re: Re-nameing a database? Tom Lane <tgl@sss.pgh.pa.us>
2002-02-11 15:50 ` Re: Re-nameing a database? Naomi Walker <nwalker@eldocomp.com>
0 siblings, 2 replies; 6+ messages in thread
From: Chris Ruprecht @ 2002-02-10 22:26 UTC (permalink / raw)
To: pgsql-admin
Hi all,
is there an easy way to re-name a database?
Best regards,
Chris
--
Chris Ruprecht
Network grunt and bit pusher extraordinaíre
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Re-nameing a database?
2002-02-10 22:26 Re-nameing a database? Chris Ruprecht <chrup999@yahoo.com>
@ 2002-02-11 00:07 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-02-11 00:14 ` Re: Re-nameing a database? Chris Ruprecht <chrup999@yahoo.com>
1 sibling, 1 reply; 6+ messages in thread
From: Tom Lane @ 2002-02-11 00:07 UTC (permalink / raw)
To: Chris Ruprecht <chrup999@yahoo.com>; +Cc: pgsql-admin
Chris Ruprecht <chrup999@yahoo.com> writes:
> is there an easy way to re-name a database?
Officially, no. Unofficially, since 7.1 it should work to UPDATE the
appropriate row in pg_database. I think. Better try it on a test
database...
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Re-nameing a database?
2002-02-10 22:26 Re-nameing a database? Chris Ruprecht <chrup999@yahoo.com>
2002-02-11 00:07 ` Re: Re-nameing a database? Tom Lane <tgl@sss.pgh.pa.us>
@ 2002-02-11 00:14 ` Chris Ruprecht <chrup999@yahoo.com>
0 siblings, 0 replies; 6+ messages in thread
From: Chris Ruprecht @ 2002-02-11 00:14 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-admin
Thanks, Tom, I will play around with it a bit.
Best regards,
Chris
At 19:07 -0500 02/10/2002, Tom Lane wrote:
>Chris Ruprecht <chrup999@yahoo.com> writes:
>> is there an easy way to re-name a database?
>
>Officially, no. Unofficially, since 7.1 it should work to UPDATE the
>appropriate row in pg_database. I think. Better try it on a test
>database...
>
> regards, tom lane
--
Chris Ruprecht
Network grunt and bit pusher extraordinaíre
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Re-nameing a database?
2002-02-10 22:26 Re-nameing a database? Chris Ruprecht <chrup999@yahoo.com>
@ 2002-02-11 15:50 ` Naomi Walker <nwalker@eldocomp.com>
2002-02-11 16:43 ` Re: Re-nameing a database? Oliver Elphick <olly@lfix.co.uk>
1 sibling, 1 reply; 6+ messages in thread
From: Naomi Walker @ 2002-02-11 15:50 UTC (permalink / raw)
To: Chris Ruprecht <chrup999@yahoo.com>; pgsql-admin
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?
>
>Best regards,
>Chris
>
>--
>Chris Ruprecht
>Network grunt and bit pusher extraordinaíre
>
>_________________________________________________________
>Do You Yahoo!?
>Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>http://archives.postgresql.org
--
Naomi Walker
Chief Information Officer
Eldorado Computing, Inc.
602-604-3100 ext 242
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Re-nameing a database?
2002-02-10 22:26 Re-nameing a database? Chris Ruprecht <chrup999@yahoo.com>
2002-02-11 15:50 ` Re: Re-nameing a database? Naomi Walker <nwalker@eldocomp.com>
@ 2002-02-11 16:43 ` Oliver Elphick <olly@lfix.co.uk>
2002-02-11 17:11 ` Re: Re-nameing a database? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Oliver Elphick @ 2002-02-11 16:43 UTC (permalink / raw)
To: Naomi Walker <nwalker@eldocomp.com>; +Cc: Chris Ruprecht <chrup999@yahoo.com>; pgsql-admin
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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Re-nameing a database?
2002-02-10 22:26 Re-nameing a database? Chris Ruprecht <chrup999@yahoo.com>
2002-02-11 15:50 ` Re: Re-nameing a database? Naomi Walker <nwalker@eldocomp.com>
2002-02-11 16:43 ` Re: Re-nameing a database? Oliver Elphick <olly@lfix.co.uk>
@ 2002-02-11 17:11 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 6+ messages in thread
From: Tom Lane @ 2002-02-11 17:11 UTC (permalink / raw)
To: Oliver Elphick <olly@lfix.co.uk>; +Cc: Naomi Walker <nwalker@eldocomp.com>; Chris Ruprecht <chrup999@yahoo.com>; pgsql-admin
Oliver Elphick <olly@lfix.co.uk> writes:
>> 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:
I don't believe a postmaster restart is required. It might be a good
idea to vacuum pg_database and then force a checkpoint, however, just
to make sure the updated row is out on disk and not still hanging about
in a shared-memory buffer.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2002-02-11 17:11 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-02-10 22:26 Re-nameing a database? Chris Ruprecht <chrup999@yahoo.com>
2002-02-11 00:07 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-02-11 00:14 ` Chris Ruprecht <chrup999@yahoo.com>
2002-02-11 15:50 ` Naomi Walker <nwalker@eldocomp.com>
2002-02-11 16:43 ` Oliver Elphick <olly@lfix.co.uk>
2002-02-11 17:11 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox