Foreign keys and NULL in mySQL

后端 未结 5 1412
小蘑菇
小蘑菇 2021-01-01 15:21

Can I have a column in my values table (value) referenced as a foreign key to knownValues table, and let it be NULL whenever needed, like in the example:

Table: valu

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-01 16:01

    Yes it is quite possible to have a NULL in your foreign-key-constrained column. I just tried it. Bear in mind that if you are not using the InnoDB storage engine, your foreign key constraints will be ignored anyway.

提交回复
热议问题