ORA-10631:SHRINK clause should not be specified for this object
As I’ve worked my way through space management requirements on our Data Warehouse 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. I received this error because there is a lot of objects that our data team created and I find out afterwards. So, on with the problem.
PROBLEM:
ORA-10631:SHRINK clause should not be specified for this object SOLUTION:
This error is due to the fact that an object you are trying to shrink has an “function-based” index on it. Objects with function-based indexes cannot be shrunk. To reclaim the space you need to drop and readd the function-based index after shrinking the object*.
*Before dropping any indexes make sure you understand what the index is for and have a script prepared to replace the index. Removing an index can affect performance of the query or the application.
SCRIPT:
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 obj.owner
,obj.table_name
,(CASE WHEN NVL(idx.cnt, 0) < 1 THEN 'YES' ELSE 'NO' END) shrinkable
FROM dba_tables obj,
(SELECT table_name, COUNT(rownum) cnt
FROM dba_indexes
WHERE index_type LIKE ‘FUN%’
GROUP BY table_name) idx
WHERE obj.table_name = idx.table_name(+)
AND obj.tablespace_name = upper(‘&1’)
Here is an example of how I use this script to shrink table objects by tablespace.
begin
for i in (SELECT obj.owner
,obj.table_name
,(CASE WHEN NVL(idx.cnt, 0) < 1 THEN 'Y' ELSE 'N' END) as shrinkable
FROM dba_tables obj,
(SELECT table_name, COUNT(rownum) cnt
FROM dba_indexes
WHERE index_type LIKE ‘FUN%’
GROUP BY table_name) idx
WHERE obj.table_name = idx.table_name(+)
AND obj.tablespace_name = upper(‘&1’) and NVL(idx.cnt,0) < 1)
loop
execute immediate ‘alter table ‘||i.owner||’.’||i.table_name||’ enable row movement’;
execute immediate ‘alter table ‘||i.owner||’.’||i.table_name||’ shrink space’;
execute immediate ‘alter table ‘||i.owner||’.’||i.table_name||’ disable row movement’;
end loop;
end;
/
Current Oracle Certs
Bobby Curtis
I’m Bobby Curtis and I’m just your normal average guy who has been working in the technology field for awhile (started when I was 18 with the US Army). The goal of this blog has changed a bit over the years. Initially, it was a general blog where I wrote thoughts down. Then it changed to focus on the Oracle Database, Oracle Enterprise Manager, and eventually Oracle GoldenGate.
If you want to follow me on a more timely manner, I can be followed on twitter at @dbasolved or on LinkedIn under “Bobby Curtis MBA”.
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Hi there! I know this is kinda off topic but I’d figured I’d ask. Would you be interested in trading links or maybe guest writing a blog post or vice-versa? My site goes over a lot of the same subjects as yours and I believe we could greatly benefit from each other. If you happen to be interested feel free to send me an email. I look forward to hearing from you! Awesome blog by the way!
priligy online pharmacy But for others, it s a serious issue that s brought on by a severe sometimes life threatening health condition
Spiridonova, T does priligy work Keywords CRISPR Cas; Cre recombinase; embryonic stem cells; genome editing; rat
how to buy cheap cytotec I ovulate on my own, but have struggled getting pregnant for about the last year and a half
As is shown in Fig 7D, homozygous Lcn9 Cre males showed normal fecundity average litter size 7 can you get cytotec pills