首页 > 技术文章 > Oracel 修改字段类型(有数据的情况)

bigroc 2018-01-30 12:04 原文

1 /*修改原字段名bh为bh_tmp*/
2 alter table Tab_Name rename column bh to bh_tmp;
3 /*增加一个和原字段名同名的字段bh*/
4 alter table Tab_Name add bh varchar2(500);
5 /*将原字段bh_tmp数据更新到增加的字段bh*/
6 update Tab_Name set bh=trim(bh_tmp);
7 /*更新完,删除原字段bh_tmp*/
8 alter table Tab_Name drop column bh1;

 

推荐阅读