Обсуждение: rename database

Поиск
Список
Период
Сортировка

rename database

От
Nuwan Liyanage
Дата:
Hi,
       I am trying to rename my database; I used the following command,
Alter database postgres rename to post_dev;
but I get a error saying that the "current database may not be renamed"
I look at the documentation, and it says that I need to connect to a different database in order do that?
can someone please help me how to do that..
Thanks
alnuwan


Never miss a thing. Make Yahoo your homepage.

Re: rename database

От
Nuwan Liyanage
Дата:
Ok I think I got it. I just went ahead and updated the pg_database table and it works..


Nuwan Liyanage <alnuwan2@yahoo.com> wrote:
Hi,
       I am trying to rename my database; I used the following command,
Alter database postgres rename to post_dev;
but I get a error saying that the "current database may not be renamed"
I look at the documentation, and it says that I need to connect to a different database in order do that?
can someone please help me how to do that..
Thanks
alnuwan

Never miss a thing. Make Yahoo your homepage.


Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.

Re: rename database

От
Guillaume Lelarge
Дата:
Nuwan Liyanage wrote:
> Ok I think I got it. I just went ahead and updated the pg_database table
> and it works..
>

A better way is to connect to another database (template1 for exemple,
but you would better use another one) and fire your statement there.

Updating system table can be dangerous.


--
Guillaume.
  http://www.postgresqlfr.org
  http://dalibo.com

Re: rename database

От
"Mag Gam"
Дата:
what's the right way to rename a database then?



On Feb 6, 2008 5:33 PM, Guillaume Lelarge <guillaume@lelarge.info> wrote:
Nuwan Liyanage wrote:
> Ok I think I got it. I just went ahead and updated the pg_database table
> and it works..
>

A better way is to connect to another database (template1 for exemple,
but you would better use another one) and fire your statement there.

Updating system table can be dangerous.


--
Guillaume.
 http://www.postgresqlfr.org
 http://dalibo.com

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

              http://www.postgresql.org/docs/faq

Re: rename database

От
"Robins Tharakan"
Дата:

Rightly as Guillaume said, tampering with a system table isn't a very good idea.

This is what he suggested:
1. Lets say you are connected to Database A
2. Reconnect to Database B on the server (this database B could be any database other than A on the server)
3. Rename database A to C
4. Reconnect to C

Without step 2, step 3 would always spew the error about unable to rename the 'current database'.

Robins

---------- Forwarded message ----------
From: Mag Gam <magawake@gmail.com>
Date: Feb 7, 2008 9:22 AM
Subject: Re: [ADMIN] rename database
To: Guillaume Lelarge <guillaume@lelarge.info>
Cc: Nuwan Liyanage <alnuwan2@yahoo.com>, pgsql-admin@postgresql.org


what's the right way to rename a database then?




On Feb 6, 2008 5:33 PM, Guillaume Lelarge <guillaume@lelarge.info> wrote:
Nuwan Liyanage wrote:
> Ok I think I got it. I just went ahead and updated the pg_database table
> and it works..
>

A better way is to connect to another database (template1 for exemple,
but you would better use another one) and fire your statement there.

Updating system table can be dangerous.


--
Guillaume.
 http://www.postgresqlfr.org
 http://dalibo.com

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

              http://www.postgresql.org/docs/faq