Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

数据表有默认值,sql插入数据时不传值报错

表my_table有a,b,c三个字段;
a主键,b和c都是 int(10) unsigned NOT NULL DEFAULT '0';
执行 INSERT INTO my_table (c) VALUES ('1');
报错ERROR 1364: 1364: Field 'b' doesn't have a default value
线上线下两套环境同样,数据库表结构完全一样,线上执行正确,线下环境执行报这个错。
怀疑是不是什么地方配置有误?
mac,mysqlworkbench


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

这种情况我之前也遇到过,和Java编译器有关。目前不知道你用的jdk是什么版本的。大致应该是部署在Linux服务器上的程序,通过jdk编译后的程序在对数据库进行操作时会默认进行sql调整。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...