1

I logged into the psql console to delete some databases, but it gives me this error:

ERROR: database "production" is being accessed by other users DETAIL: There is 1 other session using the database.

How should I find the users pointing to my database?

2 Answers 2

1

You can use the pg_stat_activity view. It will show pretty much everything that is of interest about every open session, such as the user (usename), where s/he is connecting from (client_addr and client_hostname), the state (active, idle, etc) and the last query (being) executed.

Sign up to request clarification or add additional context in comments.

Comments

0

You can get it from pg_user table

SELECT * FROM pg_user;

Or from pg_stat_activity view

SELECT usesysid, usename FROM pg_stat_activity;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.