#acl merlyn:read,write All:read = How to drop a PostgreSQL database if there are active connections to it = http://www.devopsderek.com/blog/2012/11/13/list-and-disconnect-postgresql-db-sessions/ Query pg_stat_activity and get the pid values you want to kill, then issue SELECT pg_terminate_backend(pid int) to them. == PostgreSQL 9.2 and above == {{{ SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'TARGET_DB' AND pid <> pg_backend_pid(); }}} == PostgreSQL 9.1 and below == {{{ SELECT pg_terminate_backend(pg_stat_activity.procpid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'TARGET_DB' AND procpid <> pg_backend_pid(); }}} = user & database = {{{ CREATE DATABASE wiki; CREATE USER wikijs with encrypted password 'wikijsrocks'; grant all privileges on database wiki to wikijs; }}} = pgloader import sqlite3 to postgresql = install pgloader {{{ # pgloader.sh load database from sqlite://sqlite.db into postgresql://localhost:5432/wiki with include drop, quote identifiers, create tables, create indexes, reset sequences set work_mem to '16MB', maintenance_work_mem to '512 MB'; }}}