PostgreSQL数据库重命名

db 数据库重命名
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
WHERE datname='db_name' AND pid<>pg_backend_pid();

ALTER DATABASE db_name RENAME TO db_name_bak;

 

SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
WHERE datname='bms' AND pid<>pg_backend_pid();

ALTER DATABASE bms RENAME TO bms_dev;

 

SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
WHERE datname='bms' AND pid<>pg_backend_pid();

ALTER DATABASE bms RENAME TO bms_uat;

上一篇:postgresql 查询包含某字段的表


下一篇:PG数据库,Mybatis实现批量插入数据(常用三种方案)