Renaming or dropping a Postgres database using pgAdmin is
not a straightforward task. Follow steps bellow to get it done.
Step 1: Disconnect from the database (to be renamed).
To do this connect to a different database. ex: postgres
Step 1: Disconnect from the database (to be renamed).
To do this connect to a different database. ex: postgres
Step 2: View and delete existing connections on the database
SELECT * FROM pg_stat_activity WHERE datname = 'DB_Name';SELECT pg_terminate_backend (pid) FROM pg_stat_activity WHERE datname='DB_Name';
Step 3: Rename the database
Run all these queries in together.
SELECT * FROM pg_stat_activity WHERE datname = 'DB_Name';
SELECT pg_terminate_backend (pid) FROM pg_stat_activity
WHERE datname='DB_Name';
That’s it!
No comments:
Post a Comment