One of Datavail’s customers had found there were some tables using advanced compression features on tables, but did not have a license. We had previously tried to perform an ‘Alter Table Move…’ operation, but two tables were so large they couldn’t be moved during the outage window provided by the business. We needed to find a way to remove advanced compression to get the customer’s licensing current, but with minimal impact to the business.
Oracle has provided a package name dbms_redefinition, that can be used to perform operations on a table while keeping it online.
, options_flag=>’cons_use_pk or cons_use_rowid’); <= optional if table has PK con_use_rowid if no PK on table.
Validated space is available prior to beginning compression removal.
Assumption – that table would grow to double in size as an estimate.
Created separate undo tablespace for process, to prevent impacting other database transaction undo usage.
Create interim table that mirrors original, but without compression.
Next part is to run the compression itself.
options_flag=>dbms_redefinition.cons_use_rowid <= table doesn’t have a primary key defined.
During this run, you can validate the original table doesn’t have a lock on it allowing the application and users to access it as normal.
After table redefinition has completed, now is the time to sync up all the table updates that happened during redefinition process.
Copy table dependents to new table. This should copy all constraints, indexes and triggers using the default parameters.
Finally, tables can be switched the interim table will now be the name of the original table and vice versa. To be safe, there should be no applications accessing the table for this last step. It only takes a few seconds to perform.
Using dbms_redefinition allows the DBA to make structural changes to a table that is completely transparent to the user community. In this example the purpose was to remove advanced compression from a table, but this is appropriate for changing a non-partitioned table to partitioned, changing column order or similar types of operations.