Cause : Some portion of datafile are using by database Segment which you trying to trim.
Solution : Move / Drop all Segment extends from the region prior that you want to trim.
SQL> ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/orcln1/tbs_data01.dbf' RESIZE 1700M;
ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/orcln1/tbs_data01.dbf' RESIZE 1700M
*
ERROR at line 1:
ORA-03297: file contains used data beyond requested RESIZE value
SQL> SELECT TABLESPACE_NAME
2 FROM DBA_DATA_FILES
3 WHERE FILE_NAME ='/u01/app/oracle/oradata/orcln1/tbs_data01.dbf';
TABLESPACE_NAME
------------------------------
TBS_DATA
SQL> SELECT DISTINCT SEGMENT_TYPE,SEGMENT_NAME
2 FROM DBA_EXTENTS
3 WHERE TABLESPACE_NAME = 'TBS_DATA';
SEGMENT_TYPE SEGMENT_NAME
------------------ ---------------------------------------------------------------------------------
TABLE TEST_RECLAIM_SPACE
INDEX IND_SERIAL_NO_TEST_RECL
SQL> ALTER TABLE TEST_RECLAIM_SPACE MOVE;
Table altered.
SQL> ALTER INDEX IND_SERIAL_NO_TEST_RECL REBUILD TABLESPACE TBS_DATA;
Index altered.
SQL> purge recyclebin;
Recyclebin purged.
SQL> ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/orcln1/tbs_data01.dbf' RESIZE 1700M;
Database altered.
SQL>
Solution : Move / Drop all Segment extends from the region prior that you want to trim.
SQL> ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/orcln1/tbs_data01.dbf' RESIZE 1700M;
ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/orcln1/tbs_data01.dbf' RESIZE 1700M
*
ERROR at line 1:
ORA-03297: file contains used data beyond requested RESIZE value
SQL> SELECT TABLESPACE_NAME
2 FROM DBA_DATA_FILES
3 WHERE FILE_NAME ='/u01/app/oracle/oradata/orcln1/tbs_data01.dbf';
TABLESPACE_NAME
------------------------------
TBS_DATA
SQL> SELECT DISTINCT SEGMENT_TYPE,SEGMENT_NAME
2 FROM DBA_EXTENTS
3 WHERE TABLESPACE_NAME = 'TBS_DATA';
SEGMENT_TYPE SEGMENT_NAME
------------------ ---------------------------------------------------------------------------------
TABLE TEST_RECLAIM_SPACE
INDEX IND_SERIAL_NO_TEST_RECL
SQL> ALTER TABLE TEST_RECLAIM_SPACE MOVE;
Table altered.
SQL> ALTER INDEX IND_SERIAL_NO_TEST_RECL REBUILD TABLESPACE TBS_DATA;
Index altered.
SQL> purge recyclebin;
Recyclebin purged.
SQL> ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/orcln1/tbs_data01.dbf' RESIZE 1700M;
Database altered.
SQL>
Hi
ReplyDeleteCan you please let me know how to proceed if the segment_type are as below:
SQL> select unique(segment_type) from dba_extents where tablespace_name='SYSAUX';
SEGMENT_TYPE
--------------------
LOBINDEX
INDEX PARTITION
TABLE SUBPARTITION
NESTED TABLE
TABLE PARTITION
LOB PARTITION
LOBSEGMENT
TABLE
INDEX
CLUSTER
Also in the above example there are only two rows, at our end we have 3k+ rows. Is there any simple way to process all at a time.