作者:爱rain宝520 | 来源:互联网 | 2014-07-13 17:52
oracle添加列到指定位置oracle中,1.如果表已经装载了大量数据应该是用视图来代替最好。altertableTableNMaddNewFieldvarchar2(10)renameTableNMtoTableNMXwww.2cto.comcreateorreplace...
oracle添加列到指定位置
oracle中,
1.如果表已经装载了大量数据应该是用视图来代替最好。
alter table TableNM add NewField varchar2(10)
rename TableNM to TableNMX www.2cto.com
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", www.2cto.com
"SETTLEMENTPRICEKGTAX",
"BUSINESSMARK",
"SETTLEMENTPRICEKG",
"SETTLEMENTPRICELITERTAX",
"SETTLEMENTPRICELITER",
"OTHERMONEYAMOUNT",
"PAYMENTAMOUNT",
"REMARK",
"CREATETIME",
"CREATOR"
from
"TRANSPORTOIL"."INV_SALESSETTLEMENTDETAIL"
;
drop table INV_SALESSETTLEMENTDETAIL;
rename INV_SALESSETTLEMENTDETAIL1 to INV_SALESSETTLEMENTDETAIL;
作者 liufeng_king