Online table redefinition is a mechanism to make table structure modifications without significantly affecting the availability of the table.
You can perform online table redefinition:
Execute privileges on the DBMS_REDEFINITION package are granted to EXECUTE_CATALOG_ROLE.
grant EXECUTE_CATALOG_ROLE to sh;
grant execute on DBMS_REDEFINITION to sh;
In addition to having execute privileges on this package, you must be granted the following privileges:
The following additional privileges are required to execute COPY_TABLE_DEPENDENTS:
CAN_REDEF_TABLE determines if a given table can be redefined online. This is the first step of the online redefinition process. If the table is not a candidate for online redefinition, an error message is raised.
BEGIN
DBMS_REDEFINITION.CAN_REDEF_TABLE(
uname => 'Schema name of the table',
tname => 'Name of the table to be re-organized',
options_flag => DBMS_REDEFINITION.CONS_USE_PK
part_name => 'Name of the partition being redefined');
END;
/
where:
I have just added partitions
CREATE
TABLE "COSTS_INTERIM"
(
"PROD_ID" NUMBER NOT NULL ENABLE,
"TIME_ID" DATE NOT NULL ENABLE,
"PROMO_ID" NUMBER NOT NULL ENABLE,
"CHANNEL_ID" NUMBER NOT NULL ENABLE,
"UNIT_COST" NUMBER( 10, 2 ) NOT NULL ENABLE,
"UNIT_PRICE" NUMBER( 10, 2 ) NOT NULL ENABLE
)
PARTITION BY HASH(TIME_ID) PARTITIONS 5;
BEGIN
DBMS_REDEFINITION.START_REDEF_TABLE(
uname => USER,
orig_table => costs,
int_table => costs_interim,
options_flag => dbms_redefinition.cons_use_rowid);
END;
/
Online Table Redefinition Examples
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_REDEFINITION", line 170
ORA-06512: at "SYS.DBMS_REDEFINITION", line 2795
ORA-06512: at line 2
The table given as parameter doesn't exist.