1

I have 6gb file for SYSAUX table space in 18xe oracle database.

SYSAUX table space has 61% free space :

    select
       fs.tablespace_name                          as Tablespace,
       (df.totalspace - fs.freespace)              as Used_MB,
       fs.freespace                                as Free_MB,
       df.totalspace                               as Total_MB,
       round(100 * (fs.freespace / df.totalspace)) as Percentage_Free
    from
       (select tablespace_name, round(sum(bytes) / 1048576) TotalSpace from dba_data_files group by tablespace_name) df,
       (select tablespace_name, round(sum(bytes) / 1048576) FreeSpace from dba_free_space group by tablespace_name) fs
    where
       df.tablespace_name = fs.tablespace_name
       and df.tablespace_name = 'SYSAUX';

returns

enter image description here

So I would like to reclaim the 61% free space if possible.

Attempt 1 :

ALTER DATABASE DATAFILE '...\XE\SYSAUX01.DBF' RESIZE 5000M; 

But I'm getting the error :

ORA-03297: file contains used data beyond requested RESIZE value

Attempt 2 :

ALTER TABLESPACE SYSAUX SHRINK SPACE KEEP 5000M;

Error :

ORA-12916: cannot shrink permanent or dictionary managed tablespace

Attempt 3 :

ALTER TABLESPACE sysaux RESIZE 5000M;

Error

ORA-32773: operation not supported for smallfile tablespace SYSAUX

Does anyone know to relcaim this space please ?

Thanks.

1 Answer 1

0

First you need to find the datafiles which can be re-claimed. Run the below query to identify the datafiles of SYSAUX tablespace which needed to resize.

set verify off
set pages 1000
set lines 350
undef enter_tablespace_name
column file_name format a70 word_wrapped
column smallest format 999,990 heading "Smallest|Size|Poss."
column currsize format 999,990 heading "Current|Size"
column savings  format 999999,990 heading "Poss.|Savings"
break on report
compute sum of savings on report

column value new_val blksize
col mxfile new_val mxfile

select value from v$parameter where name = 'db_block_size'
/

select tablespace_name, count(1), max(file_id) mxfile from dba_data_files where tablespace_name='&&enter_tablespace_name'
group by tablespace_name;



column cmd format a300 word_wrapped

select /*+ PARALLEL(64) */ 'alter database datafile '''||file_name||''' resize ' ||
       round((ceil( (nvl(hwm,1)*&&blksize)/1024/1024 )+200),-2)  || 'm;'||chr(10)||'exec DBMS_LOCK.SLEEP(45);'||chr(10) 
from dba_data_files a,
     ( select file_id, max(block_id+blocks-1) hwm
         from dba_extents
                 where tablespace_name='&&enter_tablespace_name'
        group by file_id ) b
where 
        a.file_id = b.file_id(+)
  and ceil( blocks*&&blksize/1024/1024) -
      ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) > 200
and a.tablespace_name='&&enter_tablespace_name'
and a.file_id  &mxfile
/

undef enter_tablespace_name
1
  • Thanks for your answer but I didn't get how am I supposed to do with this queries. If I'm not mistakedn, I already know which datafile need to be resized. It's 'C:\...\XE\SYSAUX01.DBF'. Can you please explain more ? regards
    – user32026
    Sep 10, 2021 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.