问题现象:

测试库使用如下方式创建索引:

create index IDX_ANA_OFFICE on ANA (OFFICE_CITY, OFFICE_NO)
  tablespace IDX
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 128K
    next 128K

    minextents 1
    maxextents unlimited
    pctincrease 0
  );

报错:ORA-01654: unable to extend index GALT.IDX_OFFICE by 128 in tablespace IDX

改为默认创建:
create index IDX_ANA_PNR_OFFICE on ANA (OFFICE_CITY, OFFICE_NO)
  tablespace IDX;

查看SQL是:
  storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);

问题追查:
1、首先针对1654这个报错,MOS是这样介绍的:
Error:  ORA-01654
Text: unable to extend index %s.%s by %s in tablespace %s
-------------------------------------------------------------------------------
Cause: Failed to allocate extent for index segment in tablespace.
Action: Use the ALTER TABLESPACE ADD DATAFILE statement to add one or more
files to the specified tablespace

(1)、针对表空间不足的情况,建议使用DBA_FREE_SPACE视图进行查询(Note: 121259.1提供了若干脚本)。

(2)、另外,针对索引的问题,DBA_INDEXES视图则描述了下一个分区(NEXT_EXTENT)的大小,以及所有索引的百分比增长(PCT_INCREASE)。“next_extent”指的是试图分配的区大小(也就是报错中涉及的内容)。
区分配计算:next_extent = next_extent * (1 + (pct_increase/100))
在Concept中描述了为段分配区的算法
How Extents Are Allocated
Oracle uses different algorithms to allocate extents, depending on whether they are locally managed or dictionary managed. With locally managed tablespaces, Oracle looks for free space to allocate to a new extent by first determining a candidate datafile in the tablespace and then searching the datafile’s bitmap for the required number of adjacent free blocks. If that datafile does not have enough adjacent free space, then Oracle looks in another datafile.
MOS也提出了若干可能的解决方法:
Possible solutions:
------------------
- Manually coalesce adjacent free extents:
ALTER TABLESPACE <tablespace name> COALESCE;
The extents must be adjacent to each other for this to work. - Add a datafile:
ALTER TABLESPACE <tablespace name> ADD DATAFILE '<full path and file
name>' SIZE <integer> <k|m>; - Resize the datafile:
ALTER DATABASE DATAFILE '<full path and file name>' RESIZE <integer> <k|m>; - Enable autoextend:
ALTER DATABASE DATAFILE '<full path and file name>' AUTOEXTEND ON
MAXSIZE UNLIMITED; - Defragment the Tablespace - Lower "next_extent" and/or "pct_increase" size:
ALTER <segment_type> <segment_name> STORAGE ( next <integer> <k|m>
pctincrease <integer>); 
下面这句话我认为是重点:
 “这个错误并未指出表空间中是否有足够的空间,仅仅说明Oracle不能找到一个足够大的连续空间用来匹配next extent。


2、另一篇文章“TROUBLESHOOTING GUIDE (TSG) - UNABLE TO CREATE / EXTEND Errors”说明了各种关于“UNABLE TO CREATE / EXTEND”的错误。
        “unable to extend"的错误是指当没有足够连续的空间用来分配段的情况。

I. 提出了解决这种错误所需要的信息:
(1)、判断报错表空间中最大的连续空间是多少。
SELECT max(bytes) FROM dba_free_space WHERE tablespace_name = '<tablespace name>';
        这个SQL返回的是表空间最大允许的连续块大小。(DBA_FREE_SPACE不会返回临时表空间的信息,可以参考“DBA_FREE_SPACE Does not Show Information about Temporary Tablespaces (文档 ID 188610.1)
”这篇文章会介绍如何查看临时表空间的连续块大小)。
        如果在这个报错之后立即执行上述SQL,则返回的表空间中连续的最大块会小于这个对象正在试图分配的next extent的空间。

(2)、判断NEXT_EXTENT大小。
a) 对于PCT_INCREASE=0的字典管理表空间(DMT)或者使用统一UNIFORM区管理的本地管理表空间(LMT),使用如下SQL:
SELECT NEXT_EXTENT, PCT_INCREASE
FROM DBA_SEGMENTS
WHERE SEGMENT_NAME = <segment name>
AND SEGMENT_TYPE = <segment type>
AND OWNER = <owner>
AND TABLESPACE_NAME = <tablespace name>;
其中segment_type会展示在错误信息中,可能包含如下类型的segment:
CLUSTER
INDEX
INDEX PARTITION
LOB PARTITION
LOBINDEX
LOBSEGMENT
NESTED TABLE
ROLLBACK
TABLE
TABLE PARTITION
TYPE2 UNDO
TYPE2 UNDO (ORA-1651)
同样地,segment_name可以在错误信息中找到。
b) 对于使用SYSTEM|AUTOALLOCATE区管理的本地管理表空间(LMT)。
没有方法可以查询它的next extent大小。只能查询错误信息,错误信息中的块数乘以表空间的块大小,以此来判断需要创建的区大小。
c) 对于PCT_INCREASE>0的字典管理表空间(DMT)。
SELECT EXTENT_MANAGEMENT FROM DBA_TABLESPACES WHERE TABLESPACE_NAME = '<tablespace name>';
使用如下公式计算需要分配的区大小:
extent size = next_extent * (1 + (pct_increase/100) 
例如:
next_extent = 512000
pct_increase = 50 
next extent size = 512000 * (1 + (50/100)) = 512000 * 1.5 = 768000
注意:
ORA-01650 Rollback Segment
pct_increase仅用于Oracle若干早期版本,后面版本中回滚段的pct_increase默认是0。
ORA-01652 Temporary Segment
临时段与表空间创建的存储默认值相同。
如果查询出现错误,则需要判断这个查询语句是否尽可能地最优以完成排序。

(3)、判断表空间是否包含了AUTOEXTENSIBLE,并已经达到MAXSIZ。
对于数据文件:
SELECT file_name, bytes, autoextensible, maxbytes FROM dba_data_files WHERE tablespace_name='<tablespace name> '; 
对于临时文件:
SELECT file_name, bytes, autoextensible, maxbytes FROM dba_temp_files WHERE tablespace_name='<tablespace name> '; 

(4)、判断哪种解决方法最优。
        如果NEXT EXTENT的容量(步骤2或3)大于空闲空间最大的连续块,那么“Manually Coalesce Adjacent Free Extents”是个选择。如果coalesce后仍旧没有足够的连续空间,那么可能需要其他的选项。
        如果表空间的数据文件/临时文件的卷有足够的空间,那么添加数据文件/临时文件或消除表空间碎片化可能管用,将这个文件添加到新卷中。
        如果表空间是AUTOEXTENSIBLE并且已经MAXSIZE,那么需要提高最大容量(确认有足够的卷空间),或者添加数据文件/临时文件,或者消除碎片化。
        如果NEXT EXTENT的容量(步骤2或3)小于空闲空间最大的连续块,那么就需要联系Oracle支持。

II. 可能的解决方案:
(1)、手工合并相邻的空闲区。
ALTER TABLESPACE <tablespace name> COALESCE;
(2)、将一个或多个数据文件/临时文件修改为使用AUTOEXTEND。
ALTER DATABASE DATAFILE|TEMPFILE '<full path and name>' AUTOEXTEND ON MAXSIZE <integer> <k | m | g |
注意:强烈建议明确MAXSIZE参数,防止数据文件/临时文件消耗卷上的所有可用空间。
(3)、添加数据文件/临时文件。
ALTER TABLESPACE <tablespace name> ADD DATAFILE|TEMPFILE '<full path and file name>' SIZE <integer> <k | m | g | t | p | e>;
(4)、如果段是字典管理表空间,可以降低“next_extent”和/或“pct_increase”的大小。
对于非临时段和非分区段:
ALTER <SEGMENT TYPE> <segment_name> STORAGE ( next <integer> <k | m | g | t | p | e> pctincrease <integer>); 
对于非临时段和分区段:
ALTER TABLE <table_name> MODIFY PARTITION <partition_name> STORAGE ( next <integer> <k | m | g | t | p | e> pctincrease <integer>);
对于临时段:
ALTER TABLESPACE <tablespace name> DEFAULT STORAGE (initial <integer> <k | m | g | t | p | e> next <integer> <k | m | g | t | p | e> pctincrease <integer>);
(5)、重改数据文件/临时文件的大小。
ALTER DATABASE DATAFILE|TEMPFILE '<full path and file name>' RESIZE <integer> <k | m | g | t | p | e>;
(6)、消除表空间的碎片。

附录:和此类解决方法相关的报错:
ORA-1650: unable to extend rollback segment %s by %s in tablespace %s
  Cause: Failed to allocate an extent of the required number of blocks for a rollback segment in the tablespace.
  Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.

ORA-1651: unable to extend save undo segment by %s in tablespace %s
  Cause: Failed to allocate an extent of the required number of blocks for saving undo entries for the indicated offline tablespace.
  Action: Check the storage parameters for the SYSTEM tablespace. The tablespace needs to be brought back online so the undo can be applied.

ORA-1652: unable to extend temp segment by %s in tablespace %s
  Cause: Failed to allocate an extent of the required number of blocks for a temporary segment in the tablespace indicated.
  Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.

ORA-1653: unable to extend table %s.%s by %s in tablespace %s
  Cause: Failed to allocate an extent of the required number of blocks for a table segment in the tablespace indicated.
  Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.

ORA-1654: unable to extend index %s.%s by %s in tablespace %s
  Cause: Failed to allocate an extent of the required number of blocks for an index segment in the tablespace indicated.
  Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.

ORA-1655: unable to extend cluster %s.%s by %s for tablespace %s
  Cause: Failed to allocate an extent of the required number of blocks for a cluster segment in tablespace indicated.
  Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.

ORA-1658: unable to create INITIAL extent for segment in tablespace %s
  Cause: Failed to find sufficient contiguous space to allocate INITIAL extent for segment being created.
  Action: Use ALTER TABLESPACE ADD DATAFILE to add additional space to the tablespace or retry with a smaller value for INITIAL

ORA-1659 unable to allocate MINEXTENTS beyond %s in tablespace %s
  Cause: Failed to find sufficient contiguous space to allocate MINEXTENTS for the segment being created.
  Action: Use ALTER TABLESPACE ADD DATAFILE to add additional space to the tablespace or retry with smaller value for MINEXTENTS, NEXT or PCTINCREASE

ORA-1683: unable to extend index %s.%s partition %s by %s in tablespace %s
  Cause: Failed to allocate an extent of the required number of blocks for index segment in the tablespace indicated.
  Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.

ORA-1688: unable to extend table %s.%s partition %s by %s in tablespace %s
  Cause: Failed to allocate an extent of the required number of blocks for table segment in the tablespace indicated.
  Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.

ORA-1691: unable to extend lob segment %s.%s by %s in tablespace %s
  Cause: Failed to allocate an extent of the required number of blocks for LOB segment in the tablespace indicated.
  Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.

ORA-1692: unable to extend lob segment %s.%s partition %s by %s in tablespace %s
  Cause: Failed to allocate an extent of the required number of blocks for LOB segment in the tablespace indicated.
  Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.

ORA-3233: unable to extend table %s.%s subpartition %s by %s in tablespace %s
  Cause: Failed to allocate an extent for table subpartition segment in tablespace.
  Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.

ORA-3234: unable to extend index %s.%s subpartition %s by %s in tablespace %s
  Cause: Failed to allocate an extent for index subpartition segment in tablespace.
  Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.

ORA-3238: unable to extend LOB segment %s.%s subpartition %s by %s in tablespace %s
   Cause: An attempt was made to allocate an extent for LOB subpartition segment in tablespace, but the extent could not be allocated because there is not enough space in the tablespace indicated.
   Action: Use the ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the tablespace indicated.



总结:
针对上面案例中的错误,总体讲是空间不足导致的,之所以使用第二个SQL可以,原因可能就是这种参数值设置下的满足可以空闲空间连续块的容量,上面采用的是减小extent分配大小的方式,另外上面提到的扩大文件、修改参数值、消除碎片化等方法都可以尝试使用。

ORA-01654错误的更多相关文章

  1. ORA 00972 错误处理

    Oracle 11G SQL 写好的脚本执行后报错:ORA 00972 标识符过长 可能的原因一: select 语句中的字段别名太长,中文字符别名最长为10个汉字,简化别名名称,问题得到解决. 可能 ...

  2. navicat cannot load oci dll||oracle 改字符集为GBK后 navicat 连不上||Ora-28547 ora net错误

    此段适用于 解决 navicat cannot load oci dll 环境 Navicat Premium  和 oracle 原因,navicat 32 和64 都只支持 32位的oci.dll ...

  3. 关于oracle 11g导出数据时 报 ORA 1455错误的处理

    因为导出的该用户的表可能存在空数据表,那么可能就会出现此其异常. 首先:  查看:     SQL>show parameter deferred_segment_creation;  假设为T ...

  4. plsql 连接oralce数据库,报ora 12557 tns 协议适配器不可加载错误

    使用plsql 连接oracle 数据库报ora 12557 错误: 解决方案: 1:首先确保服务中的service以及监听器都开启 2:F:\app\Administrator\product\11 ...

  5. Oracle的常见错误及解决办法

    ORA-12528: TNS:listener: all appropriate instances are blocking new connections ORA-12528问题是因为监听中的服务 ...

  6. RMAN duplicate from active遇到ora-17167,ora-12154

    最近在从活动数据库进行异机克隆时碰到了ORA-17629,ORA-17627,ORA-12154的错误,起初以为是一个Bug呢.Oracle Bug着实太多了,已经成了习惯性思维了.汗!错误提示是无法 ...

  7. VS asp.net 连接64位oracle 11g

    vs2010 vs2013 vs2015 无法连接oracle 11g 64bit 尝试加载 Oracle 客户端库时引发 BadImageFormatException......... A.安装o ...

  8. Oracle静态监听与动态监听概念全解析

    基于11g,linux5.5做出的测试,单实例数据库做出的测试. 1.注册 Instance到监听器去注册自己的Instance_name与ORACLE_HOME,还可以选择添加global_dbna ...

  9. Oracle 基于 RMAN 的不完全恢复(incomplete recovery by RMAN)

    Oracle 数据库可以实现数据库不完全恢复与完全恢复.完全恢复是将数据库恢复到最新时刻,也就是无损恢复,保证数据库无丢失的恢复.而不完全恢复则是根据需要特意将数据库恢复到某个过去的特定时间点或特定的 ...

  10. RMAN duplicate from active 时遭遇 ORA-17627 ORA-12154

    最近在从活动数据库进行异机克隆时碰到了ORA-17629,ORA-17627,ORA-12154的错误,起初以为是一个Bug呢.Oracle Bug着实太多了,已经成了习惯性思维了.汗!错误提示是无法 ...

随机推荐

  1. springboot之异步调用@Async

    原文:http://www.cnblogs.com/xuwenjin/p/8858050.html 引言: 在Java应用中,绝大多数情况下都是通过同步的方式来实现交互处理的:但是在处理与第三方系统交 ...

  2. 咏南中间件支持DELPHI6及以上版本开发的客户端

    咏南中间件支持DELPHI6及以上版本开发的客户端 下面是测试用DELPHI7开发的客户端,调用DELPHI10.3.1开发的中间件,完全兼容. 这样,有利于维护原来用D7开发的老程序. 如上所述,只 ...

  3. 初识安卓小程序(Android电话拨号器)

    首先,先创建一个安卓项目(我的版本号是4.4.2的),名字为"电话拨号器",创建的时候点击"clipart",如图: 然后在res目录下找到layout目录,找 ...

  4. 64位Windows操作系统中的注冊表

    x64系统上有x64.x86两种注冊表,记录下. 64 位Windows系统中的注冊表分为 32 位注冊表项和 64 位注冊表项.很多 32 位注冊表项与其对应的 64 位注冊表项同名. 在64位版本 ...

  5. SeekBar的用法和自定义滑块的样式

    SeekBar继承自ProgressBar,所以基本一样,我们自定义一般也就是顶一个滑块的图片而已. 布局文件 <RelativeLayout xmlns:android="http: ...

  6. Dubbo的一些编码约定和设计原则

    编码约定 代码风格 Dubbo 的源代码和 JavaDoc 遵循以下的规范: Code Conventions for the Java Programming Language How to Wri ...

  7. go语言之进阶篇多任务资源竞争问题

    1.多任务资源竞争问题 示例: package main import ( "fmt" "time" ) //定义一个打印机,参数为字符串,按每个字符打印 // ...

  8. c#中的数组、ArrayList、List区别【转】

    首先说明C#中的Array类:Array 类是 C# 中所有数组的基类,它是在 System 命名空间中定义.Array 类提供了各种用于数组的属性和方法.关于Array类的一些属性及方法详见博文:C ...

  9. 一个可用来记录Isilon各个节点的CPU,网络,磁盘性能的命令

    通过查看命令isi statistics system的帮助信息,拼出了下面的命令. isi statistics system list --nodes=all --degraded --forma ...

  10. Android -- Annotation

    Override Annotation @Override public void onCreate(Bundle savedInstanceState){}; 概念 An annotation is ...