Author Topic: force drop database on postgres cli command line  (Read 157 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2075
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
force drop database on postgres cli command line
« on: กรกฎาคม 12, 2021, 01:29:43 PM »
=== postgres force drop database
If found error :
 database "boss_v2" is being accessed by other users
 DETAIL:  There are 2 other sessions using the database.

==fixed by force drop
REVOKE CONNECT ON DATABASE boss_v2 FROM public;
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'bot’;
==and drop again
drop database boss_v2;

===when create found problem try to template0
CREATE DATABASE dbname TEMPLATE template1;
=If template1 is not available or corrupted, you can use template0 as last resort:
CREATE DATABASE dbname TEMPLATE template0;

ลองกันดูนะครับผม  8)