PostgreSQL修改库名
修改数据库名
alter database db1 rename to db2;
处理时常见错误如下:
ERROR: database "db1" is being accessed by other users DETAIL: There are 17 other sessions using the database.
处理办法:
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity WHERE datname='db1' AND pid<>pg_backend_pid();
-- 再次修改 alter database db1 rename to db2;