PL / SQL逐行删除数据

编程入门 行业动态 更新时间:2024-10-28 18:32:00
本文介绍了PL / SQL逐行删除数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 任何人都可以告诉我如何从主表格中逐行删除数据&子表中的值使用循环。我有一个主表与其他表有一个外键关系。我想要的是,我需要从主表&获取ID使用此ID我想删除其他表中的数据以及主表内容。 *从主表中获取ID *删除子表中包含从主表中获取的相同ID的值。 *从主表中删除主ID行。 这是一个数据库清理过程,包含垃圾数据。 我也是PL\SQL的新手。 谢谢&问候, Jagadisha.N 我尝试过:

声明 your_variable varchar2( 19 ); BEGIN FOR x IN ( SELECT COORDINATEDVERSIONID FROM Mastertable 其中 ISCURRENTVERSION = 0 order by coordinatedversionid asc )LOOP FOR y IN ( DELETE FROM Childtable where coordinatedversionidid = x.COORDINATEDVERSIONID order by coordinatedversionid asc DELETE FROM Mastertable 其中 coordinatedversionidid = x.COORDINATEDVERSIONID )LOOP END LOOP; END LOOP; END ;

解决方案

查看此... Oracle / PLSQL:带级联删除的外键 [ ^ ] 希望这对您有所帮助。 干杯

Hi all, Can anybody tell me how to delete data row by row from a master table & values in the child table using a loop. I have a master table which has got a foreign key relationship with other table. What i want is, i need to fetch the ID from master table & with this ID i want to delete the data present in the other table, along with the master table content. *Get ID from Master table *Delete the values in child table containing the same ID that was fetched from Master table. *Delete that Master ID row from master table. This is done a process of database cleanup, which contain junk data. Also i am new to PL\SQL. Thanks & regards, Jagadisha.N What I have tried:

Declare your_variable varchar2(19); BEGIN FOR x IN (SELECT COORDINATEDVERSIONID FROM Mastertable where ISCURRENTVERSION = 0 order by coordinatedversionid asc) LOOP FOR y IN (DELETE FROM Childtable where coordinatedversionid = x.COORDINATEDVERSIONID order by coordinatedversionid asc DELETE FROM Mastertable where coordinatedversionid = x.COORDINATEDVERSIONID ) LOOP END LOOP; END LOOP; END;

解决方案

Hi, Check this... Oracle/PLSQL: Foreign Keys with cascade delete[^] Hope this will help you. Cheers

更多推荐

PL / SQL逐行删除数据

本文发布于:2023-07-22 12:39:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1187590.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   PL   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!