What is meant by Error 1451 in MySQL database? -


i ran delete query in sql-yog , carried away error. can give me explanation error.

cannot delete or update parent row: foreign key constraint fails (`db_lakshyaassets3`.`lss_entity`, constraint `fk_lss_entity_aid` foreign key (`address_id`) references `lss_address` (`address_id`)) 

one of properties of foreign key constraint is used prevent actions destroy links between tables. therefore cannot delete rows in table shares foreign key constraints table without deleting in parent first.

you can handle in 2 ways:

  • use foreign key on delete cascade (which delete child rows if parent deleted) reference

  • use foreign key on delete no action (which deletes parent without exceptions, data become meaningless)

you getting error because default property on delete restrict

hth


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -