oracle解决修改字段类型提示null的问题

直入主题

--创建相同临时表
create table MET_ERR_ANAL_DET_TMP01 as select * from MET_ERR_ANAL_DET_TMP where 1=2
---复制相同表数据
insert into MET_ERR_ANAL_DET_TMP01 select * from MET_ERR_ANAL_DET_TMP


select t.detect_pf1_lmax_demo, t.detect_pf1_lmax,t.*  from MET_ERR_ANAL_DET_TMP t
----修改字段类型
alter table MET_ERR_ANAL_DET_TMP modify (detect_pf1_lmax VARCHAR2(20));

---第一步 增加临时字段
alter table MET_ERR_ANAL_DET_TMP  add detect_pf1_lmax_demo VARCHAR2(20);
;
--第二步 将值付给临时字段,目标字段赋值为null
update MET_ERR_ANAL_DET_TMP  set detect_pf1_lmax_demo=detect_pf1_lmax, detect_pf1_lmax = null;

--第三步 
 alter table MET_ERR_ANAL_DET_TMP  modify detect_pf1_lmax number;

--第四步
update MET_ERR_ANAL_DET_TMP  set detect_pf1_lmax=detect_pf1_lmax_demo, detect_pf1_lmax_demo= null;

--删除字段
alter table MET_ERR_ANAL_DET_TMP drop column detect_pf1_lmax_demo;
 

发布了33 篇原创文章 · 获赞 32 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/DaisyLoveZly/article/details/81939859