如何从引用主键的表中删除行? [英] how to delete rows from the table it reference primary key?

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

问题描述

你好,

我们有两个表PRODUCT和ORDER
ORDER参考产品主键,
当我们删除订单行时,会产生外键冲突,
当我们删除对应于PRODUCT ROW的订单行时该怎么做?

感谢和问候
vinay

hello,

we having two table PRODUCT and ORDER
ORDER reference product primary key,
when we delete order rows foreign key conflict arise,
how to make when we delete order rows corresponding PRODUCT ROW also delte?

thanks and regards
vinay

推荐答案

您需要在删除级联时使用 :

http://msdn.microsoft.com/en-us/library/aa933119%28v = sql.80%29.aspx [ ^ ]

希望对您有所帮助:)

有关更多查询,请在此处评论!
you need to use on delete cascade:

http://msdn.microsoft.com/en-us/library/aa933119%28v=sql.80%29.aspx[^]

hope it helps :)

for further queries comment here!


嗨Vinayfirstblock,

删除明细表中的一行会导致错误,这很奇怪!如果您告诉您,当您从PRODUCT删除一行时遇到一些错误,我不会奇怪,但是现在您很奇怪地收到了这个错误.可能还有另一个表包含有关ORDER信息的详细信息.无论如何,尝试设置与ORDER表的所有关系并将其删除规则设置为级联.

希望对您有帮助.
Hi Vinayfirstblock,

It''s very strange that deleting a row in detail table causes an error ! if you told that when you delete a row from PRODUCT and you got some errors I wouldn''t wonder but now it''s very strange that you got this error. May be there is another table that has detail information about the ORDER info. Anyway try to set all the relationships with ORDER table and set their Delete Rule to Cascade.

Hope It Helps.


首先从表中删除已引用为外键的行.

然后从具有主键约束的表中删除它(行).
First delete row from table which has refrenced as foreign key.

Then delete it(row) from table which has primary key Constraint.


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

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