Thread: Rename database?

Rename database?

From
"Wei Weng"
Date:
Can I use a SQL statement to rename database?
 
e.g Rename Database Bank to Database Bank_backup
 
Thanks!
 
Wei
 

Re: Rename database?

From
Bruce Momjian
Date:
Uh, we have ALTER DATABASE, but it doesn't rename.  If no one is
connected, you can connect to template1 and modify pg_database table to
rename.  That _should_ work.

---------------------------------------------------------------------------

Wei Weng wrote:
> Can I use a SQL statement to rename database?
> 
> e.g Rename Database Bank to Database Bank_backup
> 
> Thanks!
> 
> Wei

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


Re: Rename database?

From
"codeWarrior"
Date:
No.

Try instead

CREATE DATABASE newname FROM TEMPLATE oldname;
DROP DATABASE oldname;


""Wei Weng"" <wweng@kencast.com> wrote in message
news:000c01c2c32b$09526500$5301a8c0@monet...
> This is a multi-part message in MIME format.
>
> ------=_NextPart_000_0009_01C2C301.1FA1DB80
> Content-Type: text/plain;
> charset="Windows-1252"
> Content-Transfer-Encoding: quoted-printable
>
> Can I use a SQL statement to rename database?
>
> e.g Rename Database Bank to Database Bank_backup
>
> Thanks!
>
> Wei
>
> ------=_NextPart_000_0009_01C2C301.1FA1DB80
> Content-Type: text/html;
> charset="Windows-1252"
> Content-Transfer-Encoding: quoted-printable
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>
> <META http-equiv=3DContent-Type content=3D"text/html;
charset=3Dwindows-125=
> 2">
> <META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
> <STYLE></STYLE>
> </HEAD>
> <BODY bgColor=3D#ffffff>
> <DIV><FONT size=3D2>Can I use a SQL statement to rename
database?</FONT></D=
> IV>
> <DIV><FONT size=3D2></FONT> </DIV>
> <DIV><FONT size=3D2>e.g Rename Database Bank to Database
Bank_backup</FONT>=
> </DIV>
> <DIV><FONT size=3D2></FONT> </DIV>
> <DIV><FONT size=3D2>Thanks!</FONT></DIV>
> <DIV><FONT size=3D2></FONT> </DIV>
> <DIV><FONT size=3D2>Wei</FONT></DIV>
> <DIV> </DIV></BODY></HTML>
>
> ------=_NextPart_000_0009_01C2C301.1FA1DB80--
>