如题,我在一张表里设计了这样一张字段,枚举集合为('used','receive','invalid','deleted')
,设置了默认字段receive,并且设置非空,sql语句如下:
`status` enum('used','receive','invalid','deleted') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'receive' COMMENT '使用状态'
当我在实际插入数据的时候,并没有去设置这个字段的值,结果是插入可以成功,但是查看插入数据的时候,发现这个字段的值为空,难道我设置了默认值,他不会自动把receive填充进去的吗?还有我之前设置了非空,那个字段显示为空,但是竟然插入成功了,这是为什么呢?
Have you used an ORM? Check to see if the model in your ORM has a default value configured
Post the result of your show create table
Post the SQL statement that failed to insert
Just don’t write this field when inserting~ Don’t write insert into tb values(1,2,3,null); instead write insert into tb (a,b,c) values(1,2,3 ), in this case the status will be inserted into the default value receive