我很好奇为什么有些非空列已经设置了默认值,但在插入SQL脚本时,却会抛出错误。
以下是样例表格:
drop table if exists `delivery`;
create table `delivery`(
`price` BIGINT not null default 0,
`created_time` TIMESTAMP(6) not null default CURRENT_TIMESTAMP (6)
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4
;
假设执行以下三条语句,只有第二条语句不会抛出错误
insert into `delivery` (`price`,`created_time`) values (null, null);
insert into `delivery` (`price`,`created_time`) values (1, null);
insert into `delivery` (`price`,`created_time`) values (null, now());
有没有办法在 bigint 数据类型列中插入 null 并使其成功执行?有关逻辑的任何想法?