Table Partitioning: An Example: Don Bertsch Live Oak Telecom Oracle DBA
Table Partitioning: An Example: Don Bertsch Live Oak Telecom Oracle DBA
Don Bertsch
Live Oak Telecom
Oracle DBA
Procedural Overview
• Create partitioned copy of table (including
indexes)
• Cutover from old table to new
• Drop original (non-partitioned) table
• Maintain new partitions as table grows
Requirements
• Disk space equivalent to that of space
occupied by non-partitioned table
• Version 8i or later of Oracle server
– Partitioning available in Oracle 8, but don't
know about exchange partition command
– Oracle 7 uses different method, based upon
views
STEP 1
• Backup Datafiles
• Drop dummy table
– Is now empty
Repeat Procedure
• Add Partition
– Use ALTER TABLE ADD PARTITION command
• Create two tablespaces
• Build dummy table and indexes
– Place each in tablespace
– Range must match partition
• Gather Statistics
• Swap Partitions
• Make Tablespaces Read Only
• Drop dummy table
• Continue till reaching current time period
Synchronize Tables
• Add last partition
• Create two current tablespaces
– Make locally managed
– Place on raid 1 or 0 + 1 disks.
– Size larger
• Stop all modifications to non-partitioned table
• Build final dummy table and dummy indexes
• Swap table and indexes with final partition
– Tables are effective copies of one another.
STEP 2
Cutover From
Old Table to New
Rename Old (Non-Partitioned)
Table and Indexes
• Use RENAME TO command for table
• For Indexes, use ALTER INDEX
RENAME TO command
Name New (Partitioned) Table
and Indexes Same as Old
• Use RENAME TO command
• Use ALTER INDEX RENAME TO
command
• Is critical names match, so that privileges,
stored outlines and code hints work
STEP 3
Drop Original
(Non-Partitioned) Table
STEP 4