[TOC] # KILL ## 描述 该语句用来终止一个会话。 **说明** 如果您拥有 PROCESS 权限,则您可以查看所有会话。如果您拥有 SUPER 权限,您可以终止所有会话和语句。否则,您只能查看和终止您自己的会话和语句。 ## 格式 ~~~ KILL [CONNECTION | QUERY] 'sessionid' ~~~ ## 参数解释 <table data-tag="table" id="table-ako-trv-dtu" class="table"><colgroup width="145" span="1" data-tag="col" id="col-j4m-zbs-u8n" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="480" span="1" data-tag="col" id="col-ezb-yz9-koz" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-t9a-mma-gf5" class="thead"><tr id="tr-j29-2ks-96i"><th id="td-oky-j1j-9u0"><p id="p-7a7-0q4-ec8"><b>参数</b></p></th><th id="td-bsy-pf6-g58"><p id="p-4gs-r8t-44j"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-gh7-7ec-gk2" class="tbody"><tr data-tag="tr" id="tr-13q-qpk-i95" class="tr"><td data-tag="td" id="td-dnj-tck-n23" class="td"><p data-tag="p" id="p-x3m-bei-9p8" class="p">KILL CONNECTION</p></td><td data-tag="td" id="td-oe1-ke0-mfy" class="td"><p data-tag="p" id="p-h51-1xc-7id" class="p"><span data-mce-style="font-size: 11px" data-tag="span" id="span-exv-q3r-yeg" class="span">与不含修改符的KILL一样,可终止给定的</span><span data-mce-style="font-size: 11px" data-tag="span" id="span-exv-q3r-yeg" class="span"><em data-tag="em" id="em-rqc-e0y-447" class="em">threadid</em></span><span data-mce-style="font-size: 11px" data-tag="span" id="span-exv-q3r-yeg" class="span">。</span></p></td></tr><tr data-tag="tr" id="tr-6lu-7jf-b6j" class="tr"><td data-tag="td" id="td-yx1-y2j-qjv" class="td"><p data-tag="p" id="p-ulp-7q2-ldc" class="p">KILL QUERY</p></td><td data-tag="td" id="td-3a0-c74-u7e" class="td"><p data-tag="p" id="p-szq-eop-g8j" class="p">可终止连接当前正在执行的语句,但是会保持连接的原状。</p></td></tr></tbody></table> ## 示例 终止 sessionid 为 3221638213 的会话连接当前正在执行的语句后,再终止该会话。 ~~~ OceanBase(admin@test)>show processlist; +------------+-------+--------------------+------+---------+------+--------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +------------+-------+--------------------+------+---------+------+--------+------------------+ | 3221638212 | admin | 1.11.111.127:11161 | test | Query | 0 | ACTIVE | show processlist | | 3221638213 | admin | 1.11.111.127:11161 | test | Query | 0 | ACTIVE | select "abcedfg" | +------------+-------+--------------------+------+---------+------+--------+------------------+ 1 row in set (0.03 sec) OceanBase(admin@test)>kill query 3221638213; Query OK, 0 rows affected (0.01 sec) OceanBase(admin@test)>kill 3221638212; Query OK, 0 rows affected (0.01 sec) ~~~