[Switch] PostgreSQL database rename

Beginner PostgreSQL friends may have such doubts: how to rename database has been built? Because the default PostgreSQL client pgAdmin III and no place for us to modify an existing database name. Encounter this situation, many people may choose a backup -> drop -> create - > restore method, in fact, no need.

First, make sure there is no need for users to connect to rename the database, including yourself. You may ask, I do not even go up, how to execute the command renamed it? In fact, even to other databases, such as the default postgres database to maintain.
Then, execute the following statement, suppose you want to rename the database name is now abc, want to change to cba:

ALTER DATABASE abc RENAME TO cba;


That's it.

 
Transfer from  http://www.blogjava.net/sean/archive/2008/12/17/246942.html

Guess you like

Origin www.cnblogs.com/telwanggs/p/11689846.html