我需要编写一个删除PostgreSQL数据库的脚本.它可能有很多连接,但脚本应该忽略它.
DROP DATABASE db_name当存在打开的连接时,标准查询不起作用.
我该如何解决这个问题?
PostgreSQL中是否有命令选择到给定数据库的活动连接?
psql 说我不能删除我的一个数据库,因为它有活动的连接,所以我想看看连接是什么(以及从哪些机器)
我在Mac OS X上运行Django 1.9,Postgres 9.5.1
我跑的时候 /manage.py test --settings=myproj.settings.local
我明白了:
Creating test database for alias 'default'...
Creating test database for alias 'userlocation'...
Got an error creating the test database: database "test_myproj" already exists
Type 'yes' if you would like to try deleting the test database 'test_myproj', or 'no' to cancel: yes
Destroying old test database for alias 'userlocation'...
Got an error recreating the test database: database "test_myproj" is being accessed by other users
DETAIL: There is 1 other session using …Run Code Online (Sandbox Code Playgroud) 当我尝试在 pgadmin 4 中创建名为“eCommerce”的其他数据库时,会出现此消息
错误:其他用户正在访问源数据库“template1” 详细信息:还有 2 个其他会话正在使用该数据库。
我尝试删除其他数据库但不起作用并出现
错误:无法删除模板数据库
我该怎么办?