SQL> EXEC DBMS_REDEFINITION.can_redef_table(’admin’, ‘y’);
BEGIN DBMS_REDEFINITION.can_redef_table(’admin’, ‘y’); END;
*
ERROR at line 1:
ORA-12089: cannot online redefine table “admin”.”y” with no primary
key
ORA-06512: at “SYS.DBMS_REDEFINITION”, line 139
ORA-06512: at “SYS.DBMS_REDEFINITION”, line 1770
ORA-06512: at line 1
Elapsed: 00:00:00.03
ORA-12089: cannot online redefine table “string”.”string” with no primary key
Cause: An attempt was made to online redefine a table that does not have a primary key defined on it.
Action: Do not attempt to online redefine a table that does not have a primary key defined on it.
Solution:
drop table x;
drop table y;
create table x(id number, name varchar2(20) encrypt);
insert into x values(1,’x');
commit;
alter table x add constraint pk_id primary key(id);
create table Y as
select *
from X where 1=2;
alter table y modify (name encrypt using ‘aes256′);
EXEC DBMS_REDEFINITION.can_redef_table(’admin’, ‘x’);
EXEC DBMS_REDEFINITION.start_redef_table(’admin’, ‘x’, ‘y’);
DECLARE
num_errors PLS_INTEGER;
BEGIN
DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS(
‘ADMIN’,'X’,'Y’,DBMS_REDEFINITION.CONS_ORIG_PARAMS,
TRUE, TRUE, TRUE, FALSE, num_errors, TRUE);
END;
/
EXEC DBMS_REDEFINITION.sync_interim_table(’admin’, ‘x’, ‘y’);
EXEC DBMS_REDEFINITION.finish_redef_table(’admin’, ‘x’, ‘y’);
Now, everything is ok:
SQL> select constraint_name from user_constraints where table_name=’X';
CONSTRAINT_NAME
——————————
PK_ID
SQL> select constraint_name from user_constraints where table_name=’Y';
CONSTRAINT_NAME
——————————
TMP$$_PK_ID0
Regards,
Tom