Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

deallocate segment space / reduce ASSM tablespace size

Posted on 2010-09-15
4
Medium Priority
?
890 Views
Last Modified: 2013-12-18
Hi.

I created a tablespace as ASSM and LMT with 16 M extent size. All segments are now created with 16M size  and made the tablespace size too big. It is right now around 3GB.

I later found that most of these segments have almost 80% unused blocks, Queries shown below.

Can you suggest what is the best way to reclaim space for this tablespace?  Looks like the only solution is to re-create the tablespace. Your answers will help.



set serveroutput on

declare
TOTAL_BLOCKS number;
TOTAL_BYTES number;
UNUSED_BLOCKS number;
UNUSED_BYTES number;
LAST_USED_EXTENT_FILE_ID number;
LAST_USED_EXTENT_BLOCK_ID number;
LAST_USED_BLOCK number;

begin
dbms_space.unused_space(
'ADMIN',
'JOB_DETAILS',
'TABLE',
TOTAL_BLOCKS,
TOTAL_BYTES,
UNUSED_BLOCKS,
UNUSED_BYTES,
LAST_USED_EXTENT_FILE_ID,
LAST_USED_EXTENT_BLOCK_ID,
LAST_USED_BLOCK);

dbms_output.put_line('OBJECT_NAME = FREELIST_T');
dbms_output.put_line('-----------------------------------');
dbms_output.put_line('TOTAL_BLOCKS = '||TOTAL_BLOCKS);
dbms_output.put_line('TOTAL_BYTES = '||TOTAL_BYTES);
dbms_output.put_line('UNUSED_BLOCKS = '||UNUSED_BLOCKS);
dbms_output.put_line('UNUSED BYTES = '||UNUSED_BYTES);
dbms_output.put_line('LAST_USED_EXTENT_FILE_ID = '||LAST_USED_EXTENT_FILE_ID);
dbms_output.put_line('LAST_USED_EXTENT_BLOCK_ID = '||LAST_USED_EXTENT_BLOCK_ID);
dbms_output.put_line('LAST_USED_BLOCK = '||LAST_USED_BLOCK);

end;
/

OBJECT_NAME = FREELIST_T
-----------------------------------
TOTAL_BLOCKS = 2048
TOTAL_BYTES = 16777216
UNUSED_BLOCKS = 1984
UNUSED BYTES = 16252928
LAST_USED_EXTENT_FILE_ID = 7
LAST_USED_EXTENT_BLOCK_ID = 219264
LAST_USED_BLOCK = 64

PL/SQL procedure successfully completed.

Also ran the below command:


ALTER TABLE ADMIN.JOB_DETAILS DEALLOCATE UNUSED

also tried to ALTER TABLE ... SHRINK SPACE command.
0
Comment
Question by:dbguy0
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Expert Comment

by:POracle
ID: 33689873
Is there will be no future insert in this table? If more data going to be inserted in short period of time than I suggest not to go for deallocation as it  going to occupy free space.

Any way you can try this command.

Alter table tab_name deallocate unused keep keep_size;




0
 

Author Comment

by:dbguy0
ID: 33696384
I did that, no change the tablespace segment size is 16 M. I don't think table deallocations & shrinking have any effect on this. The only solution is export importing them into a new tablespace?
0
 
LVL 8

Accepted Solution

by:
POracle earned 1000 total points
ID: 33698737
Yes, you are right.
Have to create new tablespace with smaller extent size and move object from older to new tablespace as there is only around single extent is allocated and lots of space free in it.( I don't know about situation in other segments so I assume same for all)

But, when you insert more data free space will be utilize. So if you sure that you are not going to use that space do above exercise.


0
 
LVL 15

Assisted Solution

by:Devinder Singh Virdi
Devinder Singh Virdi earned 1000 total points
ID: 33781076
You cannot deallocate extraspace less than initial extents.
You can create another tablespace, and use ALTER TABLE MOVE command.
This will invalidate indexes and views. views are not the problem, but you need to rebuild the indexes.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question