oracle 修改某字段小数位精度 需要字段未empty的解决办法

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

执行:alter table bosp_htjs_material_information modify taxrate number(16,3);
直接执行如果有数据会有报错:ORA-01440: column to be modified must be empty to decrease precision or scale

数据不是非常大的情况下解决办法:1.备份表数据,2.清空原表对应列 3.修改字段精度。4.同步更新数据值。5.截断备份的临时表并删除

--1.create table BOSP_HTJS_MATERIAL_BAK as select * from BOSP_HTJS_MATERIAL_INFORMATION;
 select * from BOSP_HTJS_MATERIAL_BAK;
 
 --2.update BOSP_HTJS_MATERIAL_INFORMATION MI set MI.FEED_NUM = null;
  select * from BOSP_HTJS_MATERIAL_INFORMATION;

 --3.alter table BOSP_HTJS_MATERIAL_INFORMATION modify FEED_NUM number(16,3);

 --4.update BOSP_HTJS_MATERIAL_INFORMATION MI set MI.FEED_NUM = (
    select MB.FEED_NUM from BOSP_HTJS_MATERIAL_BAK MB where MB.id = MI.id
 );

 --5.truncate table  BOSP_HTJS_MATERIAL_BAK;drop table BOSP_HTJS_MATERIAL_BAK;

 

转载于:https://my.oschina.net/u/1052786/blog/872234

你可能感兴趣的:(数据库,python)