Home  >  Article  >  Backend Development  >  Will it affect performance if the operation of foreign keys in mysql is set to NO ACTION?

Will it affect performance if the operation of foreign keys in mysql is set to NO ACTION?

WBOY
WBOYOriginal
2016-10-23 00:12:521434browse

RT, I just want to display the database structure more clearly in the database relationship diagram. As for the foreign key constraints, I will implement them in the code. Will setting both delete and update operations in the database to NO ACTION affect performance?

Reply content:

RT, I just want to display the database structure more clearly in the database relationship diagram. As for the foreign key constraints, I will implement them in the code. Will setting both delete and update operations in the database to NO ACTION affect performance?

The poster seems not to understand the respective functions of several foreign key constraints. Performance and not using foreign keys will certainly have an impact

CASCADE #在父表上update/delete记录时,同步update/delete掉子表的匹配记录
SET NULL #在父表上update/delete记录时,将子表上匹配记录的列设为null 要注意子表的外键列不能为not null
NO ACTION #如果子表中有匹配的记录,则不允许对父表对应候选键进行update/delete操作  
RESTRICT #同no action, 都是立即检查外键约束
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn