Solved

i want make my oracle 9i database shrink

Posted on 2009-07-09
6
1,189 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
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 connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

758 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

22 Experts available now in Live!

Get 1:1 Help Now