删除表格中的一行 [英] Deleting a row in a table

查看:89
本文介绍了删除表格中的一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个问题,其中我有一个主键约束的表( table1 )和另一个表( table2 )的表具有外键约束的表特定领域.
如果我在table1中删除一行,则会出现错误,我也需要在 table2 中删除.
有没有一种方法或查询,如果我删除 table1 中的行,则 table2 中的以下外键约束应自动删除.

预先感谢

I am facing a problem where i have a table(table1) of primary key constraint and a second table(table2) having a foreign key constraint for table one of particular field .
If i delete a row in table1 i get a error where i need to delete in table2 as well .
Is there a way or a query where if i delete a row in table1 the following foreign key constraint in table2 should automatically get deleted .

thanks in advance

推荐答案

您可以做的是将外键的删除规则设置为Cascade.请参见此处 [
What you can do is to set the Delete Rule of your foreign key to Cascade. See here[^] for steps on how to do it. What basically happens when you set it that way is that, when a record in table1 gets deleted, the corresponding record(through foreign key) in table2 will be deleted as well.


这篇关于删除表格中的一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆