Search code examples
sqldb2kill-process

How to kill a process/query in DB2


I try to optimize a query. After every change, I must wait long time that the query is finished. It is really time consuming.

Is there any way to see the executed queries and kill/stop them??


Solution

  • In the DB2 instance command line, you can type

    db2 list applications show detail
    

    In this list, you should find your process, note the application id. You can use this command to kill it:

    db2 force application (xx)
    

    Where xx is the ID (or a comma-delimited list of IDs).

    Here is the DB2 for Linux/Unix/Windows v9.7 Information Center article on FORCE APPLICATION, and here is the one for LIST APPLICATIONS. For both of these commands, you have to have the proper privileges on the database instance (most commonly SYSADM or SYSCTRL).