drop database 报错

highgo=# drop database test;
错误:  55006: 其他用户正在使用数据库 "test"
DETAIL:  那里有1个其它会话正在使用数据库.
[highgo@localhost ~]$ psql
psql (4.0.0)
Type "help" for help.

highgo=# \l
                                         List of databases
       Name        |    Owner    | Encoding |  Collate   |   Ctype    |      Access privileges
-------------------+-------------+----------+------------+------------+-----------------------------
 highgo            | highgo      | UTF8     | zh_CN.utf8 | zh_CN.utf8 |
 test_a            | test        | UTF8     | zh_CN.utf8 | zh_CN.utf8 | test=CTc/test
 test              | test        | UTF8     | zh_CN.utf8 | zh_CN.utf8 |
 template0         | highgo      | UTF8     | zh_CN.utf8 | zh_CN.utf8 | =c/highgo                  +
                   |             |          |            |            | highgo=CTc/highgo
 template1         | highgo      | UTF8     | zh_CN.utf8 | zh_CN.utf8 | =c/highgo                  +
                   |             |          |            |            | highgo=CTc/highgo
(5 rows)

highgo=# drop database test;
错误:  55006: 其他用户正在使用数据库 "test"
DETAIL:  那里有1个其它会话正在使用数据库.
highgo=# select * from pg_stat_activity where datname = 'test';
 datid |      datname      | pid  | usesysid |   usename   | application_name | client_addr  | client_hostname | client_port |         backend_start         | xact_start |          query_st
art          |         state_change          | waiting | state | backend_xid | backend_xmin |
                                                                                                                                                                         query
 26617 | test | 9319 |    16384 | partysimple | NAVICAT          | 172.16.12.10 |                 |       29821 | 2018-05-03 11:47:07.757187+08 |            | 2018-05-03 11:47:
41.441561+08 | 2018-05-03 11:47:41.442914+08 | f       | idle  |             |              | SELECT xxxx
(1 row)

highgo=# SELECT pg_terminate_backend(9319);
 pg_terminate_backend
----------------------
 t
(1 row)

highgo=# select * from pg_stat_activity where datname = 'test';
 datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start | query_start | state_change | waiting | state | ba
ckend_xid | backend_xmin | query
-------+---------+-----+----------+---------+------------------+-------------+-----------------+-------------+---------------+------------+-------------+--------------+---------+-------+---
----------+--------------+-------
(0 rows)

highgo=# drop database test;
DROP DATABASE

By 天蝎座

你可能感兴趣的:(PostgreSQL,Highgo,DB)