Solved

i want make my oracle 9i database shrink

Posted on 2009-07-09
6
1,249 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

615 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