In my system permanent data is separated from some temporary (like log). It's done by storing log tables (user-defined program log, don't mix up with system log) in a different tablespace from the main one.
So there are two tablespaces MAIN and LOG. One datafile is for each tablespace. Both datafiles maxsize is set to 4GB, their initial sizes are 8MB, and they autoextend on next 8MB.
Since I use express edition of oracle, I need them to be not more than 4GB in sum.
And it happens sometimes when I need to reduce the size of LOG datafile in order to free some space for necessary data.
Now I do it like this:
truncate table schema_name.log_table;
alter database datafile '/path/to/the/log/datafile/log1.dbf' resize 128M;
And it works, because truncate gets rid of all the information in the datafile.
But what if I came across a situation when I need to free some size for LOG tablespace from MAIN one. I truncated several tables there (or I know there's much free space in the datafile, it's allocated but not occupated by data, were used before for some operations) and now need to defragment MAIN tablespace's datafile in order to decrease it's size. Without defragmentation I get an exception:
ORA-03297: file contains used data beyond requested RESIZE value
So am I able to perform a defragmentation operation on a datafile somehow?