search
HomeDatabaseMysql TutorialORA-3233表空间相关问题处理

问题现象: 测试库使用如下方式创建索引: create index IDX_ANA_OFFICE on ANA (OFFICE_CITY, OFFICE_NO) tablespace IDX pct

问题现象:

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

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 COALESCE;
  The extents must be adjacent to each other for this to work.

- Add a datafile:
        ALTER TABLESPACE ADD DATAFILE '        name>' SIZE ;

- Resize the datafile:
        ALTER DATABASE DATAFILE '' RESIZE ;

- Enable autoextend:
        ALTER DATABASE DATAFILE '' AUTOEXTEND ON
        MAXSIZE UNLIMITED;

- Defragment the Tablespace

- Lower "next_extent" and/or "pct_increase" size:
        ALTER STORAGE ( next
        pctincrease ); 
下面这句话我认为是重点:

 “这个错误并未指出表空间中是否有足够的空间,仅仅说明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 = '';
 

        这个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 =
 AND SEGMENT_TYPE =
 AND OWNER =
 AND 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 = '';
 使用如下公式计算需要分配的区大小:

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
 

临时段与表空间创建的存储默认值相同。

如果查询出现错误,则需要判断这个查询语句是否尽可能地最优以完成排序。

相关阅读:

Oracle ORA-01555 快照过旧 说明

ORA-01078 和 LRM-00109 报错解决方法

ORA-01555超长的Query Duration时间

ORA-00471 处理方法笔记

ORA-00314,redolog 损坏,或丢失处理方法

ORA-00257 归档日志过大导致无法存储的解决办法


(3)、判断表空间是否包含了AUTOEXTENSIBLE,并已经达到MAXSIZ。

对于数据文件:

SELECT file_name, bytes, autoextensible, maxbytes FROM dba_data_files WHERE tablespace_name=' ';
 

对于临时文件:

SELECT file_name, bytes, autoextensible, maxbytes FROM dba_temp_files WHERE tablespace_name=' '; 


(4)、判断哪种解决方法最优。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What are some tools you can use to monitor MySQL performance?What are some tools you can use to monitor MySQL performance?Apr 23, 2025 am 12:21 AM

How to effectively monitor MySQL performance? Use tools such as mysqladmin, SHOWGLOBALSTATUS, PerconaMonitoring and Management (PMM), and MySQL EnterpriseMonitor. 1. Use mysqladmin to view the number of connections. 2. Use SHOWGLOBALSTATUS to view the query number. 3.PMM provides detailed performance data and graphical interface. 4.MySQLEnterpriseMonitor provides rich monitoring functions and alarm mechanisms.

How does MySQL differ from SQL Server?How does MySQL differ from SQL Server?Apr 23, 2025 am 12:20 AM

The difference between MySQL and SQLServer is: 1) MySQL is open source and suitable for web and embedded systems, 2) SQLServer is a commercial product of Microsoft and is suitable for enterprise-level applications. There are significant differences between the two in storage engine, performance optimization and application scenarios. When choosing, you need to consider project size and future scalability.

In what scenarios might you choose SQL Server over MySQL?In what scenarios might you choose SQL Server over MySQL?Apr 23, 2025 am 12:20 AM

In enterprise-level application scenarios that require high availability, advanced security and good integration, SQLServer should be chosen instead of MySQL. 1) SQLServer provides enterprise-level features such as high availability and advanced security. 2) It is closely integrated with Microsoft ecosystems such as VisualStudio and PowerBI. 3) SQLServer performs excellent in performance optimization and supports memory-optimized tables and column storage indexes.

How does MySQL handle character sets and collations?How does MySQL handle character sets and collations?Apr 23, 2025 am 12:19 AM

MySQLmanagescharactersetsandcollationsbyusingUTF-8asthedefault,allowingconfigurationatdatabase,table,andcolumnlevels,andrequiringcarefulalignmenttoavoidmismatches.1)Setdefaultcharactersetandcollationforadatabase.2)Configurecharactersetandcollationfor

What are triggers in MySQL?What are triggers in MySQL?Apr 23, 2025 am 12:11 AM

A MySQL trigger is an automatically executed stored procedure associated with a table that is used to perform a series of operations when a specific data operation is performed. 1) Trigger definition and function: used for data verification, logging, etc. 2) Working principle: It is divided into BEFORE and AFTER, and supports row-level triggering. 3) Example of use: Can be used to record salary changes or update inventory. 4) Debugging skills: Use SHOWTRIGGERS and SHOWCREATETRIGGER commands. 5) Performance optimization: Avoid complex operations, use indexes, and manage transactions.

How do you create and manage user accounts in MySQL?How do you create and manage user accounts in MySQL?Apr 22, 2025 pm 06:05 PM

The steps to create and manage user accounts in MySQL are as follows: 1. Create a user: Use CREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password'; 2. Assign permissions: Use GRANTSELECT, INSERT, UPDATEONmydatabase.TO'newuser'@'localhost'; 3. Fix permission error: Use REVOKEALLPRIVILEGESONmydatabase.FROM'newuser'@'localhost'; then reassign permissions; 4. Optimization permissions: Use SHOWGRA

How does MySQL differ from Oracle?How does MySQL differ from Oracle?Apr 22, 2025 pm 05:57 PM

MySQL is suitable for rapid development and small and medium-sized applications, while Oracle is suitable for large enterprises and high availability needs. 1) MySQL is open source and easy to use, suitable for web applications and small and medium-sized enterprises. 2) Oracle is powerful and suitable for large enterprises and government agencies. 3) MySQL supports a variety of storage engines, and Oracle provides rich enterprise-level functions.

What are the disadvantages of using MySQL compared to other relational databases?What are the disadvantages of using MySQL compared to other relational databases?Apr 22, 2025 pm 05:49 PM

The disadvantages of MySQL compared to other relational databases include: 1. Performance issues: You may encounter bottlenecks when processing large-scale data, and PostgreSQL performs better in complex queries and big data processing. 2. Scalability: The horizontal scaling ability is not as good as Google Spanner and Amazon Aurora. 3. Functional limitations: Not as good as PostgreSQL and Oracle in advanced functions, some functions require more custom code and maintenance.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version