Data truncation: Out of range value for column ‘estimate_score’
出現這個問題的原因是由于
create table qs_study_user_score_statistics
(
id bigint(20) not null auto_increment comment '主鍵id',
user_extend_id bigint(20) comment '使用者擴充id',
subject_id bigint(20) comment '科目id',
estimate_score decimal(4,2) comment '預估分',
is_valid tinyint(1) not null default 1 comment '邏輯删除0.無效1.有效',
create_by varchar(255) default '' comment '建立人',
create_time datetime comment '建立時間',
update_by varchar(255) default '' comment '更新人',
update_time datetime comment '更新時間',
remark varchar(255) default '' comment '備注',
primary key (id)
);
建表時設定的estimate_score 位數不夠,在出現了需要存入的資料 100.5 的時候,整數位置為3位,而資料庫設定的decimal(4,2) 4表示總共的資料為長度;2表示小數位2位,那麼整體下來整數位隻有2位,100超過整數位最大長度而存入異常,根據此處業務需求将總長度改為6位即可
ALTER TABLE qs_study_user_score_statistics MODIFY COLUMN estimate_score decimal(6,2) DEFAULT NULL COMMENT '預估分';