Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to delete all rows of a table having a circular relation ?

Andy FrédéricDec 7 2018 — edited Dec 7 2018

Hi all,

There is a table having a one-to-many relation to itself :

create table structure

(

   struct\_code          varchar2(15)  not null,

   str\_struct\_code      varchar2(15),

   niv\_struct\_code      varchar2(5),

   struct\_lib           varchar2(255),

   constraint pk\_structure primary key (struct\_code),

   constraint fk\_structur\_associati\_structur foreign key (str\_struct\_code)

      references structure (struct\_code)

);

Here are sample data :

structure.PNG

So how to delete all rows from this table starting from the rows which have no child records till the top rows which have no parent rows ?

This post has been answered by Franck N on Dec 7 2018
Jump to Answer
Comments
Post Details
Added on Dec 7 2018
4 comments
507 views