On Tue, Jul 30, 2013 at 7:50 AM, Leonardo M. Ramé <l.r...@griensu.com>wrote:
> Hi, I need to do an alter table on a small table (~300 records), but it > never ends. It may be because there are clients using that table. > > How can I force disconnect all clients to let me alter that table?. > If you are using PostgreSQL 9.2+, you can use this: select pg_cancel_backend(pid) from pg_stat_activity where pid <> pg_backend_pid(); If you are using earlier version, replace "pid" with "procpid". That query will cancel all queries other than the session issuing the pg_cancel_backend() calls.