DB2删除不了数据库 The database is currently in use
[db2inst1@i-kf8i6iym ~]$ db2 drop db SLP_DEMO
SQL1035N The database is currently in use. SQLSTATE=57019
SQL1035N The database is currently in use. SQLSTATE=57019
#查看该实例下有几个数据库
[db2inst1@i-kf8i6iym ~]$ db2 list db directory
System Database Directory
Number of entries in the directory = 2
Database 1 entry:
Database alias = SLP_DEMO
Database name = SLP_DEMO
Local database directory = /home/db2inst1
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =Database 2 entry:
Database alias = SLPDB
Database name = SLPDB
Local database directory = /home/db2inst1
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
System Database Directory
Number of entries in the directory = 2
Database 1 entry:
Database alias = SLP_DEMO
Database name = SLP_DEMO
Local database directory = /home/db2inst1
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =Database 2 entry:
Database alias = SLPDB
Database name = SLPDB
Local database directory = /home/db2inst1
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
解决办法:
1.如果该实例下只有1个数据库,可直接执行
db2 force application all #断开所有的应用连接
2.如果该实例下有多个数据库,则方法1不适用。
可用方法如下:
[db2inst1@i-kf8i6iym ~]$ db2 list application
Auth Id Application Appl. Application Id DB # of
Name Handle Name Agents
——– ————– ———- ————————————————————– ——– —–
DB2INST1 db2jcc_applica 10439 192.168.100.3.57044.150506011319 SLPDB 1
DB2INST1 db2jcc_applica 90 192.168.100.3.51757.150505060702 SLPDB 1
DB2INST1 db2jcc_applica 774 192.168.100.3.52077.150505071424 SLPDB 1
DB2INST1 db2jcc_applica 10392 192.168.100.3.57014.150506010805 SLPDB 1
DB2INST1 db2jcc_applica 16563 192.168.100.3.59628.150507022619 SLPDB 1
DB2INST1 db2jcc_applica 16306 192.168.100.3.59412.150507011537 SLPDB 1
DB2INST1 db2jcc_applica 13102 192.168.100.3.58133.150506084908 SLPDB 1
DB2INST1 db2jcc_applica 81 192.168.100.3.51750.150505060653 SLPDB 1
DB2INST1 db2jcc_applica 705 192.168.100.3.52045.150505070728 SLPDB 1
DB2INST1 db2jcc_applica 10678 192.168.100.3.57141.150506014621 SLPDB 1
DB2INST1 db2jcc_applica 79 192.168.100.3.51747.150505060625 SLPDB 1
DB2INST1 db2jcc_applica 13125 192.168.100.3.58146.150506085305 SLPDB 1
DB2INST1 db2jcc_applica 16794 192.168.100.1.61159.150507033506 SLP_DEMO 1
DB2INST1 db2jcc_applica 12681 192.168.100.6.54510.150506070820 SLP_DEMO 1
DB2INST1 db2jcc_applica 12672 192.168.100.6.54504.150506070802 SLP_DEMO 1
找出和要删除的数据库 SLP_DEMO 相关的Handle,然后使用db2 force application (id)进行断开
[db2inst1@i-kf8i6iym ~]$ db2 “force application (12681)”
[db2inst1@i-kf8i6iym ~]$ db2 “force application (12672)”
[db2inst1@i-kf8i6iym ~]$ db2 “force application (16794)”
断开后再尝试删除
[db2inst1@i-kf8i6iym ~]$ db2 drop db SLP_DEMO
DB20000I The DROP DATABASE command completed successfully.
DB20000I The DROP DATABASE command completed successfully.