删除具有外键约束的行 [英] Deletion of rows with foreign key constraints

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

问题描述

我正在处理一项要求.

I am working on a requirement.

有一个表.我想从该表中删除一行,但是我不能删除它,因为

There is one table.I want to delete a row from this table but i cannot delete it because

1.该表由79表通过外键关系引用 2.这79个表中的每个表都由其他100个表

1.This table is referred by 79 table through foreign key relationship 2.Each of those 79 tables are referred by other 100's of table

所以您可以想象它的树状结构.因此,我需要从底部开始并到达TOP.我需要通过SQL来完成

so you can imagine its kind of tree structure.So i need to start from bottom and reach to TOP.I need to do it through SQL

所以我应该从哪里开始???我需要创建一个临时表或任何我可以做的有用的方法吗?

So from where I should start ???Do i need to create a temp table or anything which i can do any approach which can be useful???

注意:不允许删除CASCADE

Note:CASCADE DELETE NOT ALLOWED

我可能无权访问任何sys表.任何方便的方法???我正在使用oracle 10g

I might not have access to any sys tables.. any approach that can be handy??? I am using oracle 10g

推荐答案

请参阅: http: //www.techonthenet.com/oracle/foreign_keys/disable.php

ALTER TABLE table_name
disable CONSTRAINT constraint_name;

只需确保了解执行此过程的后果以及它将对其他数据/应用程序功能产生的影响.

Just be sure to understand the consequences of doing such a procedure and the effects it will have on other data / application functions.

此外,如果不太明显,请确保随后启用约束

Also, if it wasn't obvious be sure to enable the constraint afterwards

ALTER TABLE table_name
enable CONSTRAINT constraint_name;

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

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