Skip site navigation (1) Skip section navigation (2)

Re: Who's attached to the database?

From: Jeff Frost <jeff(at)frostconsultingllc(dot)com>
To: Carol Walter <walterc(at)indiana(dot)edu>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Who's attached to the database?
Date: 2008-07-03 19:55:14
Message-ID: 486D2EA2.7040805@frostconsultingllc.com (view raw or flat)
Thread:
Lists: pgsql-admin
Carol Walter wrote:
> I'm trying to drop a database and I'm getting an error that says that 
> the database is being accessed by other users.  Is there a way I can 
> find out who these users are or if there really is a user accessing it?
Carol, depending on version and options turned on in the 
postgresql.conf, you probably can have a look in the pg_stat_activity 
system view:

SELECT datname, client_addr FROM pg_stat_activity WHERE datname = '<db 
you're trying to drop>';

Otherwise, you can also have a look at the command line on linux servers 
like this:

ps -ef|grep postgres

or

ps aux | grep postgres

depending what ps variant your system includes.

-- 
Jeff Frost, Owner 	<jeff(at)frostconsultingllc(dot)com>
Frost Consulting, LLC 	http://www.frostconsultingllc.com/
Phone: 650-780-7908	FAX: 650-649-1954


In response to

pgsql-admin by date

Next:From: paul sochaDate: 2008-07-03 19:55:41
Subject: Re: Who's attached to the database?
Previous:From: Tom LaneDate: 2008-07-03 19:54:25
Subject: Re: Who's attached to the database?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group