Solved

i want make my oracle 9i database shrink

Posted on 2009-07-09
6
1,204 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
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Via a live example, show how to take different types of Oracle backups using RMAN.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now