Oracle数据库修改字段类型

问题

数据库中某表字段为number类型,需要修改成varchar类型。

修改步骤

--备份表
--create table xxtable_copy20171215 as select * from xxtable;
--复制表结构成新表
--create table xxtable_new as select * from xxtable where 1=2;
--改变新表的数据结构
--alter table xxtable_new modify (CANCELRENO varchar(25));

--导入原数据
--insert into xxtable_new select * from xxtable_copy20171215;
--插入新数据
--insert into xxtable_new (...) values (...);

--将原表更名
--alter table xxtable rename to xxtable_bak20171215;
--将新表更名成原表名
--alter table xxtable_new rename to xxtable;

--删除第一次备份的表
--drop table xxtable_copy20171215;

你可能感兴趣的:(oracle)