Hi
I'm trying to understand the shrink space behaviors when dealing with multiple tables with multiple lob columns sharing a single tablespace. We've 3 tables (e.g. T1, T2, T3) with each table having a lob column. And the lob columns are stored in a single tablespace called Lobspace (comprised of 3 datafiles). Recently we decided to delete all the data from the tables and thought that it'd good to free up some of our data storage. Since we're on Oracle11, I thought we could use online shrink space cascade to reclaim the free space and follow by datafile resize. Here's what I did:
1. delete from T1;
delete from T2;
delete from T3;
2. alter table T1 enable row movement;
alter table T2 enable row movement;
alter table T3 enable row movement;
alter table T1 shrink space cascade;
alter table T2 shrink space cascade;
alter table T3 shrink space cascade;
3. After a long wait, I checked dba_extents and dba_free_space:
SELECT de.file_id, ddf.file_name, ddf.bytes/1024/1024 "File size (MB)", block_id first_block, block_id+de.blocks-1 last_block, segment_name
FROM dba_extents de, dba_data_files ddf
WHERE de.tablespace_name = 'LOBSPACE' AND de.file_id=ddf.file_id
union all
SELECT dfs.file_id, ddf.file_name, ddf.bytes/1024/1024 "File size (MB)", block_id, block_id+dfs.blocks-1, 'free'
FROM dba_free_space dfs, dba_data_files ddf
WHERE dfs.tablespace_name = 'LOBSPACE' AND dfs.file_id=ddf.file_id
ORDER BY file_id, first_block
/
I found most of the segments were marked free. In my three datafiles, two of them were completed free while one of them still got three segments corresponding to the three lob columns.
4. Next I checked the HWM with the query provided by Tom:
https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:766625833673 To my surprise, I saw no change in the HWM from the original values before the shrink.
Now here're my questions:
1. Why HWM isn't adjusted after I ran the shrink space cascade command even though the tablespace was freed. According to Oracle doc, shrinking of lob is supported in Oracle 10gR2 and up.
2. I found that one way to adjust the HWM was to move the lob column within the same tablespace, e.g.
alter table T1 move lob(lob_column) stored as (tablespace LOBSPACE);
But it'd require a table lock during the move, which is something I want to avoid.
3. After the lob move, I succeeded to resize two of the datafiles that were empty. But the last datafile still contained some segments like SYS_LOBxxxxxx. As I said earlier, there're 3 segments corresponding to the 3 lob columns from the 3 tables. Each segment was 64k. Since all the tables were empty, what're these remaining segments? Is there a way to get rid of them? Also, they're not "packed" in the datafile. Thus the last datafile couldn't be resized properly.
thanks