Solved

i want make my oracle 9i database shrink

Posted on 2009-07-09
6
1,242 Views
Last Modified: 2013-12-19
Hi,
i know i must full export and import to new db and shinkage is ok. but how:)
1 how can i full export my database
2 how can i create empty db
3 how to make import first steps dump file into second steps db

thx
0
Comment
Question by:hasankaan
[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
  • 3
  • 2
6 Comments
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 24817874
1) exp / full=Y file=full_db_exp.dmp
2) Use dbca
3) imp / full=Y file=full_db_exp.dmp
 
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24817890
It is not required to export/import to reorg / shrink your database. You can do it all online.

Are there specific tables / tablespaces that you want to shrink?

You can defragment tables:

alter table a move;
-- then rebuild indexes on that table
alter index a_ix1 rebuild;


Or you can write a script to move all tables in a tablespace to a new tablespace, then drop the old one, and the defrag will happen along the way.

0
 

Author Comment

by:hasankaan
ID: 24818115
i want all my tablespaces to shrink
all XXX.DBF files
my oracle db folders size is very big 30GB :) i want this decrease
0
Webinar: MongoDB® Index Types

Join Percona’s Senior Technical Services Engineer, Adamo Tonete as he presents “MongoDB Index Types, How, When and Where Should They be Used?” on Wednesday, July 12, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7).

 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24818159
Determine which datafiles have space and try resizing them to smaller size. Oracle will shrink it if there is unallocated space at the end of the file.

alter database datafile '/ora/oradata/ORA1/foo.dbf' resize 1G;

You may also have to reorg tables in the tablespace before shrinking it will work, using the 'alter table move' command.
0
 

Author Comment

by:hasankaan
ID: 24818321
"Or you can write a script to move all tables in a tablespace to a new tablespace, then drop the old one, and the defrag will happen along the way."

can u write sample script ?

0
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 500 total points
ID: 24818474
Assume tablespace XXX and you want to defrag all tables and indexes.

1) Find the objects that need moving, there may be more than just tables.

SQL> select owner, segment_name, segment_type from dba_segments where tablespace_name = 'XXX';

2) Create a new tablespace XXX_NEW with smaller size and autoextend on.

create tablespace xxx_new datafile .... size ...;


3) Tables A is in schema OWNER is moved with:

alter table owner.a move tablespace XXX_NEW;

4) Index are moved with:

alter index owner.a_ix rebuild tablespace XXX_NEW;



You can create this script automatically by using SQL to generate the DDL:

Read this article about generated DDL from the dictionary:
  http://www.experts-exchange.com/articles/Database/Oracle/Timesavers-Using-SQL-as-a-code-generator.html

Then try this to generate some scripts for tables:

select 'alter table '|| owner||'.'||segment_name||' move tablespace XXX_NEW;' from dba_segments where tablespace_name = 'XXX' and segment_type = 'TABLE';


This is a sample, it is up to you to generate statements for indexes and also to check if all objects are moved from the old tablespace. Then you can drop  the old tablespace. You can then rename the XXX_NEW tablespace to XXX.


0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

734 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