SELECT * FROM pg_stat_activity; OR SELECT datid, datname, pid, usename, state, query FROM pg_stat_activity;