declare
size Int;Begin
size :=0;SelectCount(1)Into size From SqlUpgradeLog Where ID ='脚本id';If size =0Then--total改名为tmp_totalexecute immediate 'alter table order rename column total to tmp_total';--添加total字段,同时赋予我们需要的精度execute immediate 'alter table order add total NUMBER(24,4) default 0 NOT NULL';--重新把原值赋给totalexecute immediate 'update order set total = tmp_total';--删除tmp_totalexecute immediate 'alter table order drop column tmp_total';InsertInto SqlUpgradeLog(id,time,desc)values('脚本id',sysdate,'描述');commit;EndIf;End;
declare
size Int;Begin
size :=0;SelectCount(1)Into size From SqlUpgradeLog Where ID ='脚本id';If size =0Then--total改名为tmp_totalexecute immediate 'alter table order rename column total to tmp_total';--添加total字段,同时赋予我们需要的精度execute immediate 'alter table order add total NUMBER(24,4) NULL';--重新把原值赋给totalexecute immediate 'update order set total = tmp_total';--把total改为not nullexecute immediate 'alter table order modify (total NUMBER(24,4) NOT NULL)';--删除tmp_totalexecute immediate 'alter table order drop column tmp_total';InsertInto SqlUpgradeLog(id,time,desc)values('脚本id',sysdate,'描述');commit;EndIf;End;