Oracle中已有数据的字段类型修改
Oracle中已有数据的字段类型修改
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删除
相关推荐
lklong 2020-11-22
oraclemch 2020-11-06
shilukun 2020-10-10
周嘉笙 2020-11-09
iilegend 2020-10-19
EricRay 2020-10-16
zhuzhufxz 2020-09-16
dataminer 2020-08-17
bfcady 2020-08-16
Hody 2020-08-16
FightFourEggs 2020-08-16
数据库设计 2020-08-16
Seandba 2020-08-16
Omega 2020-08-16
zjyzz 2020-08-16
yanghuatong 2020-08-16
ktyl000 2020-08-16
dbasunny 2020-08-16