<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>惜分飞 &#187; cancel sql</title>
	<atom:link href="https://www.xifenfei.com/tag/cancel-sql/feed" rel="self" type="application/rss+xml" />
	<link>https://www.xifenfei.com</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Thu, 29 Oct 2026 15:31:46 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>18c新特性：alter system cancel sql</title>
		<link>https://www.xifenfei.com/2018/02/18c-cancel-sql.html</link>
		<comments>https://www.xifenfei.com/2018/02/18c-cancel-sql.html#comments</comments>
		<pubDate>Sun, 25 Feb 2018 08:17:42 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[ORACLE 12C]]></category>
		<category><![CDATA[ORACLE 18C]]></category>
		<category><![CDATA[18c新特性]]></category>
		<category><![CDATA[alter system cancel sql]]></category>
		<category><![CDATA[cancel sql]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=7313</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2018/02/18c-cancel-sql.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2018/02/18c-cancel-sql.html" target="_blank">18c新特性：alter system cancel sql</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>根据18c官方描述cancel sql功能是在18c中引起,但是实测发现在oracle 12.2中已经有了cancel sql功能，可以实现终止掉某个sql的当前sql正在执行的sql语句,而不是传统的直接kill某个会话.ALTER SYSTEM CANCEL SQL语句有四个参数分别为：<br />
<a href="//www.xifenfei.com"><img src="//www.xifenfei.com/wp-content/uploads/2018/02/cancel_sql.jpg" alt="cancel_sql" width="855" height="254" class="alignleft size-full wp-image-7314" /></a></p>
<pre class="brush: sql; title: ; notranslate">
--会话1
SQL&gt; set lines 150
SQL&gt; select * from v$version;

BANNER                                                                               CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production              0
PL/SQL Release 12.2.0.1.0 - Production                                                    0
CORE    12.2.0.1.0      Production                                                        0
TNS for Linux: Version 12.2.0.1.0 - Production                                            0
NLSRTL Version 12.2.0.1.0 - Production                                                    0


SQL&gt; select sid, serial# from v$session where sid in
  2  (select  sid from v$mystat where rownum=1);

       SID    SERIAL#
---------- ----------
       278       4019

SQL&gt; create table t_xifenfei tablespace users as select * from dba_source;

Table created.

SQL&gt; insert into t_xifenfei select * from t_xifenfei;

274132 rows created.                    &lt;&lt;===没有提交

SQL&gt; select count(*)from t_xifenfei;

  COUNT(*)
----------
    548264

SQL&gt; insert into t_xifenfei select * from t_xifenfei;

548264 rows created.     &lt;&lt;===没有提交

SQL&gt; select count(*)from t_xifenfei;

  COUNT(*)
----------
   1096528

SQL&gt; insert into t_xifenfei select * from t_xifenfei;


--会话2
SQL&gt; select count(*)from t_xifenfei;

  COUNT(*)
----------
    274132

SQL&gt; alter system cancel sql '278,4019';

System altered.

SQL&gt; select count(*)from t_xifenfei;

  COUNT(*)
----------
    274132

--会话1
SQL&gt; insert into t_xifenfei select * from t_xifenfei;
insert into t_xifenfei select * from t_xifenfei
*
ERROR at line 1:
ORA-01013: user requested cancel of current operation

SQL&gt; select count(*)from t_xifenfei;

  COUNT(*)
----------
   1096528
</pre>
<p>这里可以看到会话1的最后一个insert被cancel，但是前面两个没有提交的insert没有被回滚/提交，看到了cancel sql的功能的实现.</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/05/%e4%bd%bf%e7%94%a8dblink%e5%af%bc%e8%87%b4%e7%9a%84-opaque_transform.html" rel="bookmark" class="crp_title">使用dblink导致的/*+ OPAQUE_TRANSFORM */</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/04/9i%e4%b8%ad%e6%b8%85%e9%99%a4%e7%89%b9%e5%ae%9a%e8%a1%a8%e7%9b%b8%e5%85%b3%e6%89%a7%e8%a1%8c%e8%ae%a1%e5%88%92.html" rel="bookmark" class="crp_title">9I中清除特定表相关执行计划</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/04/12c-%e4%bd%bf%e7%94%a8sequence%e4%bd%9c%e4%b8%ba%e5%88%97%e9%bb%98%e8%ae%a4%e5%80%bc.html" rel="bookmark" class="crp_title">12c 使用sequence作为列默认值</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/07/oracle-11g%e5%a2%9e%e5%8a%a0%e5%88%97%ef%bc%8c%e5%b9%b6%e5%b8%a6%e9%bb%98%e8%ae%a4%e5%80%bc%e7%9a%84%e6%96%b0%e7%89%b9%e6%80%a7.html" rel="bookmark" class="crp_title">Oracle 11g增加列,并带默认值的新特性</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2020/11/19c-root-pdb-undo-lost-recovery.html" rel="bookmark" class="crp_title">模拟19c数据库root pdb undo异常恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2018/08/postgresql-schema.html" rel="bookmark" class="crp_title">PostgreSQL模式理解</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/12/%e9%80%9a%e8%bf%87rowid%e6%89%be%e5%9b%9e%e5%9d%8f%e5%9d%97%e6%95%b0%e6%8d%ae.html" rel="bookmark" class="crp_title">通过ROWID找回坏块数据</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/12/orcle-12c-%e5%a2%9e%e5%8a%a0%e5%88%97%e6%97%a0%e9%bb%98%e8%ae%a4%e5%80%bc.html" rel="bookmark" class="crp_title">ORCLE 12C 增加列,无默认值</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2018/06/truncate-table-recovery.html" rel="bookmark" class="crp_title">truncate table 无论drop storage还是reuse storage不影响数据恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/12/oracle-12c-invisible-columns-and-column-ordering.html" rel="bookmark" class="crp_title">ORACLE 12C Invisible Columns and Column Ordering</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/05/sql-profile-%e4%bd%bf%e7%94%a8.html" rel="bookmark" class="crp_title">sql profile 使用</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/08/%e6%95%b0%e6%8d%ae%e5%ba%93%e6%94%b6%e9%9b%86%e7%bb%9f%e8%ae%a1%e4%bf%a1%e6%81%af%e5%b1%9e%e4%ba%8edml%e6%93%8d%e4%bd%9c.html" rel="bookmark" class="crp_title">数据库收集统计信息属于dml操作</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2018/02/18c-cancel-sql.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
