I am trying to drop a postgres database. But I am always getting a
There is 1 other session using the database
error.
I tried stopping all the sessions with this command
select pg_terminate_backend(pid) from pg_stat_activity where datname='my_database';
this was the result
pg_terminate_backend
----------------------
(0 rows)
and then I used this command
DROP DATABASE my_database;
This is the entire error message
ERROR: database "my_database" is being accessed by other users
DETAIL: There is 1 other session using the database.
I am using postgres 12.