fruworg.github.io/content/posts/postgres-drop-db.md
root c793b55750 Revert "remove shell"
This reverts commit 65914f8895.
2023-09-24 18:58:33 +03:00

35 lines
696 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Дроп БД форсированно в Postgres
description: На старой и новой версии
date: 2023-03-03T13:26:00+05:00
tags: [linux, postgres]
---
## На старой версии (<=12)
Заходим в консоль Postgres:
```shell
psql
```
Убиваем соединения с БД:
```shell
SELECT pg_terminate_backend (pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = '<database_name>';
```
Дропаем БД:
```shell
DROP DATABASE <database_name>;
```
## На новой версии (>=13)
Заходим в консоль Postgres:
```shell
psql
```
Дропаем БД:
``` shell
DROP DATABASE <database_name> WITH (FORCE);
```