Shrink Tablespace
543974May 17 2009 — edited May 18 2009I have tabelspace that use ~50% of it size ;
I running this script to get the free size
SQL> SELECT a.tablespace_name, Sum( a.bytes )/1024/1024 allocated_bytes,
2 sum(b.free_bytes)/1024/1024 free_bytes
3 FROM dba_data_files a,
4 (SELECT file_id, SUM(bytes) free_bytes
5 FROM dba_free_space b GROUP BY file_id) b
6 WHERE a.file_id=b.file_id
7 And a.tablespace_name='TBS_BIG_DATA'
8 Group By a.tablespace_name
9 ORDER BY a.tablespace_name;
TABLESPACE_NAME ALLOCATED_BYTES FREE_BYTES
------------------------------ --------------- ----------
TBS_BIG_DATA 42500 22314.5
I tried to run the commend for all the table related to the TBS
SQL> alter table XXXXX enable row movement;
Table altered
SQL> alter table XXXXXX shrink space;
Table altered
And the commend
SQL> purge recyclebin;
Recyclebin purged.
But i still get the error "ORA-03297: file contains used data beyond requested RESIZE value"
Way it keep give me the error ?
Whet else can I do to shrink the TBS ?