How to select list of active connections to a PostgreSQL database
问题 Is there a command in PostgreSQL to select active connections to a given database? psql states that I can't drop one of my databases because there are active connections to it , so I would like to see what the connections are (and from which machines) 回答1: Oh, I just found that command on PostgreSQL forum: SELECT * FROM pg_stat_activity; 回答2: Following will give you active connections/ queries in postgres DB- SELECT pid ,datname ,usename ,application_name ,client_hostname ,client_port