简体   繁体   中英

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

I have a question about InnoDB and MyISAM storage engine of database.

Suppose we have 5 column in a table all column are set to "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. But when I do the same with InnoDB database, it generate error that "somecolumn could not be null".

My all tables are set to MyISAM type but my database is InnoDB and I am having this issue.

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. I want to know the better solution than above mentioned.

Hope it does make any sense. :)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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