Solved

i want make my oracle 9i database shrink

Posted on 2009-07-09
6
1,238 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

739 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