The short history is that we have a tablespace that was filled with 150G. Doing some cleaning and relocating shrunk this down to what should be zero. In reality, the tablespace could be dropped as it is no longer in use, but we’ll be using it again soon so I just wanted to reclaim a large portion of space.
So, the standard process –
alter database datafile ‘/u02/mydatafile.dbf’ resize 1000m;
but this returned:
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 50
ORA-03297: file contains used data beyond requested RESIZE value
I checked dba_extents:
select owner, segment_name, segment_type from dba_extents where tablespace_name=’MY_TABLESPACE’;
and no rows returned.
Puzzled, I went to master Google and found this post by Connor McDonald:
https://connormcdonald.wordpress.com/2012/11/23/why-cant-i-resize-my-datafile
which says that things don’t always show in dba_extents, one must also check dba_segments – which showed the bin remnants of prior objects.
Ah yes, flashback.. For him, the following purge worked:
purge recyclebin;
but the data remained and thus the datafile still wouldn’t resize.
The magic fix:
purge dba_recyclebin;
and the datafile resized with ease. *sigh*