Home >Database >Mysql Tutorial >Oracle中已有数据的字段类型修改

Oracle中已有数据的字段类型修改

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 16:46:581128browse

Oracle中已有数据的字段类型修改 create table t_person(id varchar2(200) primary key,name varchar2(200),address varchar2(20

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删除

 

 

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn