简体   繁体   English

MySql InnoDB - 在表的“Not Null”列中插入

[英]MySql InnoDB - Insertion in “Not Null” column of table

I have a question about InnoDB and MyISAM storage engine of database. 我对InnoDB和MyISAM数据库存储引擎有疑问。

Suppose we have 5 column in a table all column are set to "Not Null". 假设我们在一个表中有5列,所有列都设置为“Not Null”。 When I run a query to insert values in only two column of MyISAM database, it wont generate any error, insert the record into table and left the other columns empty by default. 当我运行查询只在MyISAM数据库的两列中插入值时,它不会生成任何错误,将记录插入表中并默认将其他列保留为空。 But when I do the same with InnoDB database, it generate error that "somecolumn could not be null". 但是当我对InnoDB数据库执行相同操作时,会产生“somecolumn not null”的错误。

My all tables are set to MyISAM type but my database is InnoDB and I am having this issue. 我的所有表都设置为MyISAM类型,但我的数据库是InnoDB,我遇到了这个问题。

Is there any way to resolve? 有什么办法可以解决吗? I have already couple of solutions that either change the type of database to MyISAM, or set every column of all table to except "Null" value. 我已经有几个解决方案要么将数据库类型更改为MyISAM,要么将所有表的每一列都设置为“Null”值。 I want to know the better solution than above mentioned. 我想知道比上面提到的更好的解决方案。

Hope it does make any sense. 希望它确实有意义。 :) :)

为所有NOT NULL列设置DEFAULT值,如果未在INSERT上指定值,则将使用默认值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM