日期:2014-05-16  浏览次数:20537 次

Orace中已有数据的字段类型修改
create table t_person(
id varchar2(200) primary key,
name varchar2(200),
address varchar2(200)
);
insert into t_person(id,name,address) values(sys_guid(),'zhangsan','beijing');
insert into t_person(id,name,address) values(sys_guid(),'lisi','shangqiu');


想把address的varchar2类型改为clob类型

(1)

alter table t_person rename column address to myaddress;

把原字段换个名字,address改为myaddress

(2)

alter table t_person add address clob;

在表中添加一个原字段名字 address 并把类型定义为自己想改变的类型,这里是clob

(3)

update t_person set address = myaddress;

把备份的myaddress字段内容添加到新建字段address中来

(4)

alter table t_person drop column myaddress;

把备份字段myaddress删除