본문 바로가기

프로그래밍

PostgresSQL 10 Drop Database with Command line





명령줄로 Postgres DB를 삭제(drop)하기 위해서 아래 두 명령을 연속 실행해야합니다.

 

C:\Program Files\PostgreSQL\10\bin> .\psql.exe --dbname=postgresql://postgres:symphony@127.0.0.1:5432 -c "select pg_terminate_backend(pid) from pg_stat_activity where datname='DB_NAME';"

 

C:\Program Files\PostgreSQL\10\bin> .\psql.exe --dbname=postgresql://postgres:symphony@127.0.0.1:5432 -c "DROP DATABASE DB_NAME;"