首页 » ORACLE » ORA-10631: SHRINK clause should not be specified for this object(原因)

ORA-10631: SHRINK clause should not be specified for this object(原因)

ORA-10631: SHRINK clause should not be specified for this object

I’ve been shrinking objects to reclaim space that is not needed. Today I was shrinking some tables and ran into the error ORA-10631.

PROBLEM:

ORA-10631:SHRINK clause should not be specified for this object SOLUTION:

SQL> alter table mytest shrink space;
alter table mytest shrink space
*
ERROR at line 1:
ORA-10631: SHRINK clause should not be specified for this object

Shrink operations can be performed only on segments in locally managed tablespaces with automatic segment space management (ASSM). Within an ASSM tablespace. Restrictions on the shrink_clause. The shrink_clause is subject to the following restrictions:

* You cannot specify this clause for a cluster, a clustered table, or any object with a LONG column.
* This clause does not shrink mapping tables of index-organized tables, even if you specify CASCADE.
* You cannot specify this clause for a compressed table.
* You cannot shrink a table that is the master table of an ON COMMIT materialized view. Rowid materialized views must be rebuilt after the shrink operation. 
* You cannt spefify this clause for a table that contains a Text index, indextype is ctxsys.context
* Segment shrink is not supported for tables with function-based indexes, domain indexes, or bitmap join indexes.

This script I’ve provided is script to help you identify what and where the “function-based” indexes are. Use at your own discretion.

  SELECT dt.owner,
         dt.table_name,
         (CASE WHEN NVL (ind.cnt, 0) < 1 THEN 'Y' ELSE 'N' END) AS can_shrink
    FROM dba_tables dt,
         (  SELECT table_name, COUNT (*) cnt
              FROM dba_indexes di
             WHERE index_type LIKE 'FUNCTION-BASED%'
          GROUP BY table_name) ind
   WHERE     dt.table_name = ind.table_name(+)
         AND dt.table_name NOT LIKE 'AQ$%'
         AND dt.table_name NOT LIKE 'BIN$%'
         AND dt.owner = '&ownername'
ORDER BY 1, 2;
打赏

对不起,这篇文章暂时关闭评论。