Data truncation: Out of range value for column ‘estimate_score‘

亦凉 2023-01-05 01:20 304阅读 0赞

Data truncation: Out of range value for column ‘estimate_score’

出现这个问题的原因是由于

  1. create table qs_study_user_score_statistics
  2. (
  3. id bigint(20) not null auto_increment comment '主键id',
  4. user_extend_id bigint(20) comment '用户扩展id',
  5. subject_id bigint(20) comment '科目id',
  6. estimate_score decimal(4,2) comment '预估分',
  7. is_valid tinyint(1) not null default 1 comment '逻辑删除0.无效1.有效',
  8. create_by varchar(255) default '' comment '创建人',
  9. create_time datetime comment '创建时间',
  10. update_by varchar(255) default '' comment '更新人',
  11. update_time datetime comment '更新时间',
  12. remark varchar(255) default '' comment '备注',
  13. primary key (id)
  14. );

建表时设置的estimate_score 位数不够,在出现了需要存入的数据 100.5 的时候,整数位置为3位,而数据库设置的decimal(4,2) 4表示总共的数据为长度;2表示小数位2位,那么整体下来整数位只有2位,100超过整数位最大长度而存入异常,根据此处业务需求将总长度改为6位即可

  1. ALTER TABLE qs_study_user_score_statistics MODIFY COLUMN estimate_score decimal(6,2) DEFAULT NULL COMMENT '预估分';

发表评论

表情:
评论列表 (有 0 条评论,304人围观)

还没有评论,来说两句吧...

相关阅读