Register Login

Can I Insert Null values in Foreign Key Constraint?

Updated May 18, 2018

Hello Experts,

Can I insert null values in Foreign Key constraint.?

Kindly suggest here, Thanks in advance.


Comments

  • 12 Aug 2015 5:39 pm Abhijeet Mudgal 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 Abhijeet Mudgal 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 Jyoti Pandey 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.


×