views:

1339

answers:

5

Hi,

I need to rename the database but when I do in PGAdmin : ALTER DATABASE "databaseName" RENAME TO "databaseNameOld" it told me that it cannot.

How can I do it?

(Version 8.3 on WindowsXP)

Update

  • The first error message : Cannot because I was connect to it. So I selected an other database and did the queries.

  • I get a second error message telling me that it has come user connect. I see in the PGAdmin screen that it has many PID but they are inactive... I do not see how to kill them.

+1  A: 

Try not quoting the database name:

ALTER DATABASE people RENAME TO customers;

Also ensure that there are no other clients connected to the database at the time. Lastly, try posting the error message it returns so we can get a bit more information.

bmdhacks
quoting is required when the name has capital letter in it.
Daok
A: 

Unexist told me in comment to restart the database and it works! Restarting the database kill all existing connection and then I connect to an other database and was able to rename it with my initial query.

Thx all.

Daok
+1  A: 

What is the exact error message and did you look up this error in the postgres docs? Maybe there's a perfect reason for that behaviour. Normally renaming should work.

If you have problems with pending or dead connections just restart the database to get rid of them.

unexist
A: 

Instead of deploying a nuke (restarting the server) you should try to close those connections that bother you either by finding where are they from and shutting down the client processes or by using the pg_cancel_backend() function.

Milen A. Radev
Thx didn't know that!
Daok
A: 

Para Ubuntu:

La solución es cambiar la variable LANG, la cuál es leída por el postgres. Esta se cambia en vi /etc/default/locale, debe quedar la siguiente línea en la vairible que se encuentra en el archivo LANG="es_CO"

Para Fedora

vi /etc/sysconfig/i18n

Nota: En caso de que ya se encuentre instalado el POstgres se debe borrar el Cluster, con el siguiente comando

Service postgresql stop o etc/init.d/postgresql stop

rm -rf /var/lib/pgsql/data. Esto es para que permita crear la base de datos Latin1.

Luego inicia el servidor

Service postgres start(sale error para que inicie el cluster)… creo q se debe dar service postgres inidb para que cree de nuevo el cluster

john velandia