Online Tutorials & Training Materials |
Register Login

Can I Insert Null values in Foreign Key Constraint?

Sugandh || 12 Aug 2015 5:39 pm || 3

Hello Experts,

Can I insert null values in Foreign Key constraint.?

Kindly suggest here, Thanks in advance.


  • 12 Aug 2015 5:39 pm Helpful Answer

    Yes. Foreign key can take Null . e.g in Emoloyee table we have employee_id and manager_id where manager_id is foregin key and CEO of the organization doesn't have manager so his manager_id will be NULL in Employee table.

  • 12 Aug 2015 5:41 pm Helpful Answer

    One more thing.. Foreign key may reference Primary key and Unique key as well and Unique key can have NULL value so foreign key can have..

  • 12 Aug 2015 5:43 pm Helpful Answer

    Yes we can.

    There is clause on delete set null used to delete parent record without deleting child record at that time foreign key value update as null.

    And directly insert null for foreign key.