If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Best way to housekeep a tablespace

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-01-09, 08:36
shajju shajju is offline
Registered User
 
Join Date: Aug 2008
Posts: 298
Best way to housekeep a tablespace

Hi

Using Oracle 9i.

I have some logical volumes that are nearing capacity. Before adding more space, I can see that if some house-keeping is performed on the db, I can gain a few GB of free space.
Part of this housekeeping is some tablespace mgmt. I have a couple of tablespaces which have 10 datafiles each, each 2GB in size but only 12% of that 2GB is used when I look at the tablespace in 'Toad'. Even when running a query.

I also ran a script to find out if I could resize the datafiles but there is no free space at the end of the file.

The next best option I'm thinking of is to Export the user, drop the existing one, re-create it and Import the user back. (Ideally I'd like to create another user first, import the data into this user and then drop the exported user if all is fine but for this I'll have to create the new user with a different name. Are there any downsides to this?

Also, am I correct in saying I'll have to take the tablespace offline?

Is there a better, simpler, more risk-free method for this?

Regards
Sheraz
Reply With Quote
  #2 (permalink)  
Old 07-01-09, 10:19
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,413
Cool Move it!

You could re-org the tables in that tablespace by "moving" them:

1) Create new tablespace.
2) Move the tables to new tablespace.
3) Drop old tablespace.


-- Or --

Try "moving" the tables within same tablespace.
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 07-01-09, 12:55
The_Duck The_Duck is offline
Registered User
 
Join Date: Jul 2003
Posts: 2,292
Oracle will still use the unused space of the datafiles. Is there a problem with that?
__________________
- The_Duck
you can lead someone to something but they will never learn anything ...
Reply With Quote
  #4 (permalink)  
Old 07-01-09, 12:59
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,153
>Is there a better, simpler, more risk-free method for this?
Yes, do nothing & allow Oracle to manage tablespace internals.
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Reply With Quote
  #5 (permalink)  
Old 07-02-09, 09:48
shajju shajju is offline
Registered User
 
Join Date: Aug 2008
Posts: 298
Yes, Oracle will still use the space but it's only like 12% in each of the 10 datafiles in 2 years so have been advised to use the free space in these datafiles for other data.

For reorg, I understand there needs to be enough free space on the disk (logical vol) in my case. But there's not. LVOL is 97% full.

I have enough free space on another lvol of abot the same size which is only 50% full.

If I create a new tablespace, how will I move the tables? (I take it moving datafiles is different?)

And I take it after I move the tables, I won't have to update anything else as all links to those tables will automatically be updated?
Reply With Quote
  #6 (permalink)  
Old 07-02-09, 11:10
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,153
If Locally Managed Tablespace, then Oracle handles all these details.
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Reply With Quote
  #7 (permalink)  
Old 07-02-09, 14:34
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,413
Talking Move it baby...

To move tables:

ALTER TABLE "SCOTT"."EMP" MOVE TABLESPACE NEW_TS_DAT1;

To move indexes:

ALTER INDEX "SCOTT"."EMP_IX0" REBUILD TABLESPACE NEW_TS_IDX1;

To shrink:

ALTER TABLE "SCOTT"."EMP" ENABLE ROW MOVEMENT;
ALTER TABLE "SCOTT"."EMP" SHRINK SPACE;


PS: If you omit the TABLESPACE clause it will reorg in the same tablespace.
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #8 (permalink)  
Old 07-03-09, 08:55
shajju shajju is offline
Registered User
 
Join Date: Aug 2008
Posts: 298
Thanks for the syntax.

Will

ALTER TABLE "SCOTT"."EMP" MOVE TABLESPACE NEW_TS_DAT1;

work even if the new tablespace is on a different logical volume?

Also is the whole procedure to move tables first and then rebuild indexes with

ALTER INDEX "SCOTT"."EMP_IX0" REBUILD TABLESPACE NEW_TS_IDX1;

The tablespaces are locally managed here.

Can I shrink tables in 9i?
Reply With Quote
  #9 (permalink)  
Old 07-03-09, 12:35
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,413
Cool Yes

Yes to all...


PS: Ooops, not sure the "shrink" syntax will work in 9i.
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On