问题现象:

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

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. Java Deadlock Example and How to analyze deadlock situation

    source:http://www.journaldev.com/1058/java-deadlock-example-and-how-to-analyze-deadlock-situation De ...

  2. C#编程(七十二)----------DynamicObject和ExpandoObject

    DynamicObject和ExpandoObject 1.ExpandoObject表示一个对象,该对象包含可在运行时动态添加和移除的成员.这个类和动态类型有关,这个类能做些什么? 案例: //Ex ...

  3. java解压缩zip和rar的工具类

    package decompress; import java.io.File; import java.io.FileOutputStream; import org.apache.tools.an ...

  4. GO -- 正则表达式

    str := "880218end" match, _ := regexp.MatchString("\\d{16}", str) //六位连续的数字 fmt. ...

  5. NSObject的hash方法

    NSObject的hash方法 说明 本示例仅仅演示一个对象什么时候执行hash方法. 细节 1. 必要的Model类,重载了hash方法用以反映Hash方法是否被调用了 2. 测试 // // Vi ...

  6. 用 iOS-System-Services 框架获取iOS设备所用的设备信息

    参考资料地址 https://github.com/Shmoopi/iOS-System-Services 百度云盘下载地址 http://pan.baidu.com/s/1c05ot1m This ...

  7. 多个so中模板单例的多次实例化

    在Android打包项目时,发现登录功能不能使用了,logcat中也没发现什么问题,最后一行一行log定位到了问题.原来是一个so文件中的构造函数被初始化二次!   这个单例是通过继承模板来实现的(暂 ...

  8. Android日志监听工具logcat命令详解(转)

    Android日志系统提供了记录和查看系统调试信息的功能.日志都是从各种软件和一些系统的缓冲区中记录下来的,缓冲区可以通过logcat命令来查看和使用. 在使用logcat之前,请确保手机的USB调试 ...

  9. Chrome浏览器导出pdf时,隐藏链接HREF

    在使用chrome打印pdf是,会出现链接的HREF也同时打印的情况,只要加一句CSS即可 @media print {   a[href]:after {     content: none !im ...

  10. APPLE框架之高效便捷的Repository解决方案

    原文地址:http://perfy315.iteye.com/blog/1460226 Spring Data JPA 转至:http://note.sdo.com/u/855924134/n/P15 ...