kill postgresql active connection

barang kali kita perlu hapus database namun gagal karena 1 atau lebih session sedang menggunakan database tersebut. error message yang dijumpai adalah:

ERROR:  database "database_name" is being accessed by other users
DETAIL:  There are 1 other session(s) using the database.

dan ketika PID di-kill, muncul error message:

kill: kill 2358 failed: operation not permitted

untuk menyiasati hal ini bisa digunakan perintah berikut:

    -- don't kill my own connection!
    pid <> pg_backend_pid()
    -- don't kill the connections to other databases
    AND datname = 'database_name'

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s