How to cancel a long-running Database operation?

前端 未结 11 955
臣服心动
臣服心动 2020-11-30 04:18

Currently working with Oracle, but will also need a solution for MS SQL.

I have a GUI that allows users to generate SQL that will be executed on the database. This

11条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 04:38

    Oracle introduced ALTER SYSTEM CANCEL SQL in 18c. You would need to add some kind of comment with UID to your SQL and then look for it something like this

    SELECT S.SID||','||S.SERIAL#
                        FROM GV$SESSION S, V$SQL Q
                        WHERE S.USERNAME IS NOT NULL
                        AND S.STATUS = 'ACTIVE'
                        AND S.SQL_ID IS NOT NULL
                        AND Q.SQL_ID = S.SQL_ID
                        and sql_text like '%{queryId}%'
    

    And then run another operation from .NET ALTER SYSTEM CANCEL SQL 'SID, SERIAL'

提交回复
热议问题