<?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; 18c新特性</title>
	<atom:link href="https://www.xifenfei.com/tag/18c%e6%96%b0%e7%89%b9%e6%80%a7/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>Wed, 04 Nov 2026 15:33:30 +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/2025/01/oracle-user-read-only.html" rel="bookmark" class="crp_title">Oracle read only用户&#8212;23ai新特性:只读用户</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>
		<item>
		<title>18c新特性：Scalable Sequences(自适应序列)</title>
		<link>https://www.xifenfei.com/2018/01/scalable-sequences.html</link>
		<comments>https://www.xifenfei.com/2018/01/scalable-sequences.html#comments</comments>
		<pubDate>Tue, 23 Jan 2018 08:09:40 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[ORACLE 12C]]></category>
		<category><![CDATA[ORACLE 18C]]></category>
		<category><![CDATA[18c新特性]]></category>
		<category><![CDATA[Scalable Sequences]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=7287</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2018/01/scalable-sequences.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/01/scalable-sequences.html" target="_blank">18c新特性：Scalable Sequences(自适应序列)</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>作为18c的新特性,其实在oracle 12.2 引入了Scalable Sequences作为一个隐藏特性，为了改善在高并发系统中，特别是使用seq作为index，大量插入记录导致index的争用，oracle自己实现了以前我们需要人工去自定义seq的方式(instance+sid+seq的类似算法方式）,该功能将在oracle 18c中正式推出,我这里带领大家先体会下<br />
<strong>SCALE/NOSCALE</strong><br />
When SCALE is specified, a numeric offset is affixed to the beginning of the sequence. This offset if of the form iii||sss||, where,<br />
iii denotes a three digit instance offset given by (instance_id % 100) + 100,<br />
sss denotes a three digits session offset given by (session_id % 1000), and<br />
|| is the concatenation operator<br />
<br />
<strong>EXTEND/NOEXTEND</strong><br />
When EXTEND is specified with the SCALE keyword, the generated sequence values are all of length (x+y), where x is the length of the scalable offset (default 6), and y is the maximum number of digits in the sequence maxvalue/minvalue. Thus, for an ascending sequence with maxvalue 100 and SCALABLE EXTEND specified, the generated sequence values are of the form iii||sss||001, iii||sss||002, …,iii||sss||100<br />
The default setting for the SCALE clause is NOEXTEND. With the NOEXTEND setting, the generated sequence values are at most as wide as the maximum number of digits in the sequence maxvalue/minvalue. This setting is useful for integration with existing applications where sequences are used to populate fixed width columns. On invocation of NEXTVAL on a sequence with SCALABLE NOEXTEND specified, a user error is thrown if the generated value requires more digits of representation than the sequence’s maxvalue/minvalue.<br />
<br />
SCALE的算法就是(instance_id % 100)(_kqdsn_instance_digits) + 100||(session_id % 1000)(_kqdsn_cpu_digits)+seq(EXTEND/NOEXTEND确定是否固定宽度）<br />
<br />
<strong>Scalable Sequences语法</strong></p>
<pre class="brush: sql; title: ; notranslate">
CREATE | ALTER SEQUENCE [ schema. ]sequence
[ { INCREMENT BY | START WITH } integer
| { MAXVALUE integer | NOMAXVALUE }
| { MINVALUE integer | NOMINVALUE }
| { CYCLE | NOCYCLE }
| { CACHE integer | NOCACHE }
| { ORDER | NOORDER }
| { SCALE {EXTEND | NOEXTEND} | NOSCALE}
]
</pre>
<p><strong>Scalable Sequences测试</strong></p>
<pre class="brush: sql; title: ; notranslate">
[oracle@xifenfei ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Jan 23 02:33:49 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production


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; set line 150 
SQL&gt; col &quot;Paramete&quot;  for a30 
SQL&gt; col &quot;Session Value&quot;  for a20
SQL&gt; col &quot;Instance Value&quot; for a20
SQL&gt; col &quot;Is Default?&quot; for a20
SQL&gt; SELECT a.ksppinm &quot;Parameter&quot;, b.ksppstvl &quot;Session Value&quot;, c.ksppstvl &quot;Instance Value&quot;,c.ksppstdf &quot;Default?&quot; 
  2  FROM x$ksppi a, x$ksppcv b, x$ksppsv c WHERE a.indx = b.indx  AND a.indx = c.indx  AND lower(a.ksppinm) 
  3  in ('_kqdsn_instance_digits', '_kqdsn_cpu_digits');

Parameter                                                Session Value        Instance Value       Default?
-------------------------------------------------------- -------------------- -------------------- ---------
_kqdsn_instance_digits                                   2                    2                    TRUE
_kqdsn_cpu_digits                                        3                    3                    TRUE

SQL&gt; select instance_number from v$instance;

INSTANCE_NUMBER
---------------
              1

SQL&gt; select sys_context('userenv','sid') from dual;

SYS_CONTEXT('USERENV','SID')
----------------------------------------------------------------------------
275


SQL&gt; create sequence seq_xff start with 1 increment by 1 minvalue 1 maxvalue 100 scale extend;

Sequence created.

SQL&gt; select seq_xff.nextval from dual;

   NEXTVAL
----------
 101275001
</pre>
<p><strong>验证效果</strong></p>
<pre class="brush: sql; title: ; notranslate">
--另外一个会话
[oracle@xifenfei ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Jan 23 02:45:14 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL&gt; select sys_context('userenv','sid') from dual;

SYS_CONTEXT('USERENV','SID')
---------------------------------------------------------
4

SQL&gt; select instance_number from v$instance;

INSTANCE_NUMBER
---------------
              1

SQL&gt; select seq_xff.nextval from dual;

   NEXTVAL
----------
 101004002
</pre>
<p>这里可以看出来seq的值是固定长度的.而且随着sid或者inst_id 不同而不同,从而实现减少大量数据集中在一个block而引起的各种争用<br />
<strong>测试scale noextend</strong></p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; create sequence seq_xifenfei start with 1 increment by 1 minvalue 1 maxvalue 100 scale noextend;

Sequence created.

SQL&gt; select seq_xifenfei.nextval from dual;
select seq_xifenfei.nextval from dual
       *
ERROR at line 1:
ORA-64603: NEXTVAL cannot be instantiated for seq_xifenfei. Widen the sequence
by 4 digits or alter sequence with SCALE EXTEND.


SQL&gt; drop sequence seq_xifenfei;

Sequence dropped.

SQL&gt; create sequence seq_xifenfei start with 1 increment by 1 minvalue 1 maxvalue 1000000 scale noextend;

Sequence created.

SQL&gt;  select seq_xifenfei.nextval from dual;

   NEXTVAL
----------
   1010041
</pre>
<p>这里可以看出来scale noextend的长度是随着seq值的改变而改变,而且max值不能小于seq本身长度.</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/04/%e6%ad%a3%e5%b8%b8%e5%85%b3%e9%97%ad%e6%95%b0%e6%8d%ae%e5%ba%93sequence-cache%e4%b8%8d%e4%b8%ba0-sequence%e4%b8%8d%e8%b7%b3%e8%b7%83.html" rel="bookmark" class="crp_title">正常关闭数据库sequence cache不为0 sequence不跳跃</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/04/db2%e4%b8%ad%e4%ba%a7%e7%94%9f%e5%94%af%e4%b8%80%e5%80%bc%e4%b8%89%e7%a7%8d%e6%96%b9%e5%bc%8f.html" rel="bookmark" class="crp_title">DB2中产生唯一值三种方式</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/03/oracle-12c-%e6%96%b0%e7%89%b9%e6%80%a7identity-columns-%e5%ae%9e%e7%8e%b0oracle%e8%87%aa%e5%a2%9e%e9%95%bf%e5%88%97%e5%8a%9f%e8%83%bd.html" rel="bookmark" class="crp_title">ORACLE 12C 新特性Identity Columns&#8212;实现ORACLE自增长列功能</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/01/%e8%ae%be%e7%bd%ae_smu_debug_mode%e5%ae%9e%e7%8e%b0%e6%8c%87%e5%ae%9asession%e7%ba%a7%e5%88%ab%e4%bd%bf%e7%94%a8%e7%89%b9%e5%ae%9a%e5%9b%9e%e6%bb%9a%e6%ae%b5.html" rel="bookmark" class="crp_title">设置_smu_debug_mode实现指定session级别使用特定回滚段</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/03/%e8%af%af%e5%88%a0%e9%99%a4dual%e8%a1%a8%e6%81%a2%e5%a4%8d.html" rel="bookmark" class="crp_title">误删除dual表恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/01/%e9%aa%8c%e8%af%81imp-show%e5%8f%82%e6%95%b0.html" rel="bookmark" class="crp_title">验证imp show参数</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2017/04/impdp-disable_archive_logging.html" rel="bookmark" class="crp_title">impdp中的DISABLE_ARCHIVE_LOGGING参数测试</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2016/06/resize-operation-completed-for-file.html" rel="bookmark" class="crp_title">Resize operation completed for file#</a></li><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/2011/02/show-hidden-parameter.html" rel="bookmark" class="crp_title">show hidden parameter</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2016/06/_use_single_log_writer%e5%92%8c_max_outstanding_log_writes.html" rel="bookmark" class="crp_title">_use_single_log_writer和_max_outstanding_log_writes</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/05/%e4%bd%bf%e7%94%a8dbms_metadata-get_ddl%e5%87%ba%e7%8e%b0ora-31605%e9%94%99%e8%af%af.html" rel="bookmark" class="crp_title">使用dbms_metadata.get_ddl出现ORA-31605错误</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2018/01/scalable-sequences.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
