1.验证表
exec DBMS_REDEFINITION.CAN_REDEF_TABLE('RMSDEV','RMS_RESUME_TAB', dbms_redefinition.cons_use_pk);
exec dbms_redefinition.can_redef_table('SCOTT','VHE',dbms_redefinition.cons_use_rowid);
2.建中间表vhe_tmp
3.开始重定义
exec dbms_redefinition.start_redef_table(uname => 'SCOTT',
orig_table => 'VHE',
int_table=> 'VHE_TMP',
options_flag => dbms_redefinition.cons_use_rowid);
4.拷贝依赖和被依赖的约束和索引信息等
DECLARE
retval NUMBER(5);
BEGIN
dbms_redefinition.copy_table_dependents(uname => 'SCOTT',
orig_table => 'VHE',
int_table => 'VHE_TMP',
copy_constraints => false,
num_errors => retval);
dbms_output.put_line(retval);
END;
5.同步数据
exec dbms_redefinition.sync_interim_table('SCOTT', 'VHE', 'VHE_TMP');
6.完成重定义
EXEC DBMS_REDEFINITION.finish_redef_table ('SCOTT', 'VHE', 'VHE_TMP');
重定义表,更改表属性将name字段varchar2类型改为number
begin
dbms_redefinition.start_redef_table(uname => 'LUOLUO',
orig_table => 'T2',
int_table=> 'T3',
col_mapping=>'id id,to_number(name) name1',
options_flag => dbms_redefinition.cons_use_rowid);
end;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25989950/viewspace-712639/ ,如需转载,请注明出处,否则将追究法律责任。