DROP DATABASE fails

John picture John · Jun 29, 2016 · Viewed 10.2k times · Source

I have a DB2 database (let's call it mydb) that I would like to delete. However, when I do db2 drop db mydb I get back

SQL1035N The operation failed because the specified database cannot be connected to in the mode requested. SQLSTATE=57019

What am I doing wrong?

Answer

Finbarr O'B picture Finbarr O'B · Jul 6, 2016

You should try the following:

db2 quiesce db immediate
db2 force application all
db2 drop database mydb

'Quiesce' forces all users off the specified instance and database and puts it into a quiesced mode. (https://www.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0008635.html)

'Force application' forces local or remote users or applications off the system to allow for maintenance on a server. (https://www.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0001951.html)

If that doesn't do the trick, do 'db2stop' and 'db2start' after the 'force application' and then drop the database