oracle添加列到指定位置

oracle中,
1.如果表已经装载了大量数据应该是用视图来代替最好。
alter table TableNM add NewField varchar2(10)
rename TableNM to TableNMX
create or replace view TableNM 
as
  select Field1,Field2,NewField ,Field3 from TableNMX

2.不是很大的数据,可以
alter table TableNM rename column Field3 to NewField 
alter table TableNM add Field3 .....
此方法涉及到Field3 ,NewField 的数据类型,数据字段间转移

3.小的数据量,倒可以考虑drop 再create

示例:

alter table INV_SALESSETTLEMENTDETAIL add

(
   realTimeQuantityKg number(13,2) default '0',
   realTimeQuantityLiter number(13,2) default '0'
)
;
create table INV_SALESSETTLEMENTDETAIL1 as 
select
        "SALESDETAILGID",
        "SETTLEMENTGID",
        "OILARCHGID",
        "ARCHNAME",
        "ARCHSPEC",
        "SALESTIME",
        "LOADINGBILLGID",
        "DENSITY",
        "TINGID",
        "SITENO",
        "OUTAMOUNTKG",
        "OUTAMOUNTLITER",
        realTimeQuantityKg,
        realTimeQuantityLiter,
        "TAXRATE",
        "SETTLEMENTPRICEKGTAX",
        "BUSINESSMARK",
        "SETTLEMENTPRICEKG",
        "SETTLEMENTPRICELITERTAX",
        "SETTLEMENTPRICELITER",
        "OTHERMONEYAMOUNT",
        "PAYMENTAMOUNT",
        "REMARK",
        "CREATETIME",
        "CREATOR"
    from
        "TRANSPORTOIL"."INV_SALESSETTLEMENTDETAIL"
        ;
drop table INV_SALESSETTLEMENTDETAIL;
rename INV_SALESSETTLEMENTDETAIL1 to INV_SALESSETTLEMENTDETAIL;

你可能感兴趣的:(oracle,oracle,添加列,制动位置)