[Solved] PostgreSQL ERROR: There is 1 other session using the database.
- Last Updated On: August 25, 2022
- By: Scriptcrunch Editorial
In PostgreSQL, if you have active connection to the database and if you try to DROP the database, you will get the following error.
ERROR: database "catalog" is being accessed by other users
DETAIL: There is 1 other session using the database.
To rectify this error and to drop the database, follow the steps given below.
Step 1: First, you need to close all the active connections from programs or tools like PGAdmin. Quit all the applications connecting to the database.
Step 2: Execute the following query from on PostgreSQL to terminate all active connections. Replace catalog
with your database name.
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'catalog';
You will get the following output.
pg_terminate_backend
----------------------
t
(1 row)
Step 3: Delete the database using the DROP command.
DROP DATABASE dvdrental;
Scriptcrunch Editorial
Other Interesting Blogs
[50% OFF] Kubernetes Certification Coupons (CKA, CKAD, CKS, KCNA and KCSA)
Looking for CKA coupon and other Kubernetes certification coupon codes? You have come to the right place. Following are the list of
[80% OFF] Linux Foundation Coupon for December 2024
Looking for CKA Coupon and other Linux Foundation certifications coupons? We got you covered. With the latest Linux Foundation Coupon, you can
[65% OFF] Linux Foundation LFCA, LFCS & LFCT Exam Voucher Codes
Linux Foundation has announced up to a $284 discount on its Linux certification programs Linux Foundation Certified IT Associate (LFCA) and Linux
1 thought on “[Solved] PostgreSQL ERROR: There is 1 other session using the database.”
thank you so much for this, been struggling to delete a database that was being used even if I disconnected from it.