我有我想重新定义的下表:
create table tq84_redefinition (
id number primary key,
ts1 timestamp not null,
ts2 timestamp
);
Run Code Online (Sandbox Code Playgroud)
请注意not null
对列的约束ts1
。
使用dbms_redefinition
,我专门使用copy_constraints => true
.
create table tq84_redefinition_int (
id number, -- Note: no primary key to prevent «ORA-01408: such column list already indexed»
ts1 date,
ts2 date,
duration_minutes as ((ts2 - ts1) * 24 * 60)
);
begin
dbms_redefinition.start_redef_table(
user, 'tq84_redefinition', 'tq84_redefinition_int',
'id, ' ||
'to_date(to_char(ts1, ''ddmmyyyyhh24miss''), ''ddmmyyyyhh24miss'') ts1, ' ||
'to_date(to_char(ts2, ''ddmmyyyyhh24miss''), ''ddmmyyyyhh24miss'') ts2'); …
Run Code Online (Sandbox Code Playgroud)