Do you have an idea or suggestion based on your experience with Azure Database for PostgreSQL?

Need a way to terminate sessions to drop and recreate a database

I have used the following script to kill connections prior to dropping, creating and loading a database on our in house postgresql instance:

SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB';

But it requires superuser rights to kill the connections which is something we don't get on Azure.

I would like some programmatic way to do this in Azure.

11 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)

    We’ll send you updates on this idea

    Ross shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    0 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base