By :
Akshay More
1
Contents
Introduction
Types of Reorg
Rebuilding the table
Export/Import
Alter table Move
CTAS method
shrinking its free space
2
Introduction
Because they are dynamic, Oracle databases will always fragment over time and
may require a periodic clean-up
3
Types of table reorganization
TYPES-
1.Export/Import
2.Alter table Move
3.CTAS method(Create table table_name2 as Select *from table_name1)
4
Types Rebuilding the table
1.Export/Import-
• The Export and Import utilities provide a simple way for you to transfer data objects
between Oracle databases.
• We can take export backup of table, tablespace or schema.
STEPS-
• Take export backup of particular Table/schema/tablespace.
expdp system/system directory=<DIR_NAME> dumpfile=<TABLE_NAME>_%U.dmp logfile=<TABLE_NAME>.log
tables=<OWNER>.<TABLE_NAME> EXCLUDE=statistics parallel=40
5
Types Rebuilding the table
Advantages-
•It handle large volume of data
•Easy to use
•Space reclaimed is more
Disadvantages –
•More downtime required.
•Time consuming process.
6
Types Rebuilding the table
2.Alter table Move-
•In this method moving the table either to another tablespace or within the same tablespace.
•Tablespace should have space equal to or greater than size of table.
•It is good for small table
STEPS-
7
Types Rebuilding the table
Advantages-
• Downtime required much less
• Used for small table/schema
Disadvantages –
• The tablespace needs to be able to store this second copy of the table
• The tables indexes, any depending objects like packages, procedures can
become INVALI D and might need to be rebuild
• There will be a table-level exclusive lock on the table involved. Any application
using that table will be affected by this lock.
8
3.CTAS Method-
• The CTAS statement is one method for reorganizing an Oracle table or moving the
table to another tablespace.
• Instead of spending hours setting up parameter files and job steps, you can copy and
rename the table
SYNTEX-
create table xxx_new
tablespace new_tablespace_name
storage (initial new_initial next new_next freelists new_freelist_number )
as
select * from xxx
order by primary_index_key_values;
9
Rebuilding the table by shrinking its free space
10
Oracle Table Reorg
Reorg of Tablespace
11
Thank You
12