添加电子书报错,字段设置为not null 但是有默认值

来源:6-12 电子书管理功能优化

慕瓜0127004

2021-10-06

图片描述
数据表的字段脚本如下:
create table ebook
(
id bigint not null comment 'id’
primary key,
name varchar(50) null comment ‘名称’,
category1_id bigint null comment ‘分类1’,
category2_id bigint null comment ‘分类2’,
description varchar(200) null comment ‘描述’,
cover varchar(200) null comment ‘封面’,
doc_count int default 0 not null comment ‘文档数’,
view_count int default 0 not null comment ‘阅读数’,
vote_count int default 0 not null comment ‘点赞数’
)
comment ‘电子书’ charset = utf8mb4;

写回答

1回答

慕粉3868778

2021-10-07

报错不是都说了文档数不能为空吗

0
2
甲蛙
回复
慕瓜0127004
mybatis生成的sql会导致default失效,需要在service设置下0
2021-10-08
共2条回复

Spring Boot+Vue3前后端分离,实战wiki知识库系统

一课掌握前后端最火框架,更有职场竞争力

2524 学习 · 1671 问题

查看课程