|
-
deleting rows from multiple tables with a single query
HI David ,
I got it. It is like below
--------------------------------------------------------------------
SQL> create table test16 (id number primary key,name varchar2(10));
Table created.
SQL> create table test17 (id number,address varchar2(10), foreign key (id) references test16(id) on
delete cascade);
Table created.
------------------------------------------------------------------------
these are the rows of the tables
SQL> select * from test16;
ID NAME
--------- ----------
100 srini
200 ram
300 sam
SQL> select * from test17;
ID ADDRESS
--------- ----------
100 add1
200 add2
300 add3
-----------------------------------------------------------------------
deleting the row in one table , so that it will delete the foreign keys of the child table.
SQL> delete from test16 where id=300;
1 row deleted.
---------------------------------------------------------------------
And checking whether the rows are deleted or not
SQL> select * from test16;
ID NAME
--------- ----------
100 srini
200 ram
SQL> select * from test17;
ID ADDRESS
--------- ----------
100 add1
200 add2
Thank you David
SrinivasM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|