Friday, July 15, 2011

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



you can set your datafile size up to HWM_BYTES columns or you can resize your HWM through alter table move + rebuild index or export and import.


SQL> select bytes/1024 from dba_data_files where file_id = 6;

BYTES/1024

----------

      7168

 

SQL> select sum(bytes/1024) from dba_segments where tablespace_name = 'EXAMPLE';

SUM(BYTES/1024)

---------------

           5440

 

SQL> alter database  datafile 'c:\oracle\product\10.1.0\oradata\db02\example01.dbf' resize 5500k;

alter database

*

ERROR at line 1:

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

 

 

You can resize your datafile upto the HWM_BYTES column value

 

SQL> ed

Wrote file afiedt.buf

 

    select  a.file_name,    a.bytes file_size_in_bytes,

    (c.block_id+(c.blocks-1)) * &BLOCK_SIZE HWM_BYTES,

     a.bytes - ((c.block_id+(c.blocks-1)) * &BLOCK_SIZE) SAVING

    from dba_data_files a,

    (select file_id,max(block_id) maximum

    from dba_extents

    group by file_id) b,

   dba_extents c

  where a.file_id = b.file_id

  and c.file_id = b.file_id

  and c.block_id = b.maximum

 and c.tablespace_name = 'EXAMPLE'

SQL> /

 

Enter value for _block_size: 8192

old   4:    (c.block_id+(c.blocks-1)) * &BLOCK_SIZE HWM_BYTES,

new   4:    (c.block_id+(c.blocks-1)) * 8192 HWM_BYTES,

Enter value for _block_size: 8192

old   5:    a.bytes - ((c.block_id+(c.blocks-1)) * &BLOCK_SIZE) SAVING

new   5:    a.bytes - ((c.block_id+(c.blocks-1)) * 8192) SAVING

 

FILE_NAME             FILE_SIZE_IN_BYTES  HWM_BYTES     SAVING

-------------------------------- ------------------ ---------- ----------

C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB02\EXAMPLE01.DBF

           7340032                      6356992                    983040

 

SQL> alter database datafile 'c:\oracle\product\10.1.0\oradata\db02\example01.dbf' resize 6356992;

Database altered.

No comments:

Post a Comment