当前位置:网站首页>Is it necessary to disconnect all connections before deleting the PostgreSQL database?
Is it necessary to disconnect all connections before deleting the PostgreSQL database?
2022-07-28 20:56:00 【Cloth clothes & mortal dust】
PostgreSQL Is it necessary to disconnect all connections before deleting the database ?
Take the answer 1:
stay PostgreSQL in , If a library is being used , We can't delete it directly , You will receive the following error :
[email protected]=>drop database db03;ERROR: database "db03" is being accessed by other usersDETAIL: There is 1 other session using the database.
therefore , We need to disable the session from connecting to the Library , Only when all currently connected sessions are disconnected at the same time .
Here are the specific operation methods :
1、 Set the database to prohibit connection
UPDATE pg_database SET datallowconn = 'false' WHERE datname = 'db_name';
2、 Interrupt all connection sessions in the current library
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'db_name';
3、 Delete database
drop database db_name;
If you are satisfied with the answer , Please click the adopt button !
Other answers 1:
stay PostgreSQL in , If a library is being used , We can't delete it directly , You will receive the following error :
[email protected]=>drop database db03;ERROR: database "db03" is being accessed by other usersDETAIL: There is 1 other session using the database.
therefore , We need to disable the session from connecting to the Library , Only when all currently connected sessions are disconnected at the same time .
Here are the specific operation methods :
1、 Set the database to prohibit connection
UPDATE pg_database SET datallowconn = 'false' WHERE datname = 'db_name';
2、 Interrupt all connection sessions in the current library
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'db_name';
3、 Delete database
drop database db_name;
If you are satisfied with the answer , Please click the adopt button !
Other answers 2:
Yes tdsql?
边栏推荐
- Job CE
- Talking about canvas and three rendering modes in unity
- 第六七八次作业
- System. ArgumentException: Object of type ‘System. Int64‘ cannot be converted to type ‘System.Int32‘
- 如何用Redis实现事物以及锁?
- Unity object path query tool
- C # basic 3-value type and reference type, packing and unpacking
- Sorting out problems in interface endpoint testing practice using Supertest
- Prometheus complete process of configuring alertmanager
- 阿里云 MSE 支持 Go 语言流量防护
猜你喜欢

Confusing knowledge points of software designer examination
![[complete collection of common ADB commands and their usage (from a comprehensive summary of [wake up on Sunday)]](/img/63/91b53b0ba718537383a97df59fe573.png)
[complete collection of common ADB commands and their usage (from a comprehensive summary of [wake up on Sunday)]

High beam software has obtained Alibaba cloud product ecological integration certification, and is working with Alibaba cloud to build new cooperation

Prize essay solicitation | 2022 cloud native programming challenge draft activity opens

Pl515 SOT23-5 single / Dual Port USB charging protocol port controller Parkson electronic agent
![Leetcode:2141. The longest time to run n computers at the same time [the maximum value is two points]](/img/33/05620dfff2f6ac67691d20c5256c5b.png)
Leetcode:2141. The longest time to run n computers at the same time [the maximum value is two points]

GIS数据漫谈(六)— 投影坐标系统

融合数据库生态:利用 EventBridge 构建 CDC 应用
Looking at SQL optimization from the whole process of one query

十七年运维老兵万字长文讲透优维低代码~
随机推荐
Integrating database Ecology: using eventbridge to build CDC applications
Introduction to redis II: RedHat 6.5 installation and use
Explain prefabrication in unity in detail
JS page black and white background switch JS special effect
What is "security"? Volvo tells you with its unique understanding and action
How to use redis to realize things and locks?
Using viewpager to slide through pages in fragment
NAT实验演示(Huawei交换机设备配置)
C # basic 7-iterator and coroutine
Prometheus complete process of configuring alertmanager
Network layer performance test
Seventeen year operation and maintenance veterans, ten thousand words long, speak through the code of excellent maintenance and low cost~
Mongoose condition queries the data of a certain time period
C# 读取 CSV文件内数据,导入DataTable后显示
一文了解 Rainbond 云原生应用管理平台
Unity foundation 4 common plug-ins
C foundation 2-encapsulation, inheritance, polymorphism
MySQL修改端口号(修改mysql的端口号会有问题吗)
Algorithm interview high frequency problem solving guide [1]
H5 wechat shooting game source code