denrepo

PostgreSQLSessions

Cancel a query or terminate a session

Try cancel first: it stops the current statement and leaves the connection open. Terminate ends the backend and rolls back its transaction.

Changes data

Not yet verified. How scripts are tested

This script changes the database. Check the names and values before you run it.
b-pg-kill.sql
1-- Replace 12345 with the pid2SELECT pg_cancel_backend(12345);     -- stop the running statement only3SELECT pg_terminate_backend(12345);  -- end the whole session

Paste it into your query tool.

Open in denrepo

More PostgreSQL scripts: Sessions