原表为Enterprise ,将其主键enterpriseid 的number类型替换为varchar(21)
方法一:
create table enterprise1 as
select * from enterprise where 1=2;
alter table enterprise1 modify(enterpriseid varchar2(21));
insert into enterprise1 select * from enterprise ;
drop table enterprise;
rename enterprise1 to enterprise ;
这样做数据不会丢失,但会丢失主键、index,字段注释,表名注释 以及相应的触发器
方法二为
新建一个字段 如enterpriseid1,类型为varchar2(20),存储原主键的值,然后修改回原主键字段名
这样做会丢失主键 约束等
Update enterprise set enterpriseid1=g||enterpriseid ;