Home » SQL & PL/SQL » SQL & PL/SQL » How to delete rows from multiple tables
How to delete rows from multiple tables [message #38404] Tue, 16 April 2002 20:55 Go to next message
T.Manikandan
Messages: 6
Registered: April 2002
Junior Member
Hi,

I am new to oracle and may be this question is easy..

I have 2 tables in which name is the primary key and in both tables, names are equal. I want to delete the
rows in both tables with certain criteria.

Ex :

Table A

Name Value

abc 5
edf 6

Table B

Name salary number

abc 10000 66
edf 11111 77

I want to delete the rows from both the tables
where Name = abc and A.value <= 5.


Any help is appreciated..

Thanks..
Re: How to delete rows from multiple tables [message #38407 is a reply to message #38404] Wed, 17 April 2002 00:07 Go to previous messageGo to next message
Epe
Messages: 99
Registered: March 2002
Member
Hello,

first of all, check if there are constraints linking the two tables. It's possible that if you delete the record in table A, all records with the same name in table B will be deleted...
If not, then you can do it simply by using two delete statements :
delete from table A
where name = 'abc'
and value <= 5;
Use the same statement with table B afterwards.
If you want to "save" this change : commit.

Success,

epe
Re: How to delete rows from multiple tables [message #38410 is a reply to message #38404] Wed, 17 April 2002 01:29 Go to previous messageGo to next message
T.Manikandan
Messages: 6
Registered: April 2002
Junior Member
Hi epe,

Thanks a lot for your kind reply.

I want to delete the rows in both tables in a single
query.In both table the tables Name value is unique.
Hence i want to delete the rows in both tables
in a single query with by checking one constraint in
the table A.

Thanks.
Re: How to delete rows from multiple tables [message #38443 is a reply to message #38404] Wed, 17 April 2002 21:14 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
The only way to accomplish this in one statement is to have a delete trigger on table a that deletes the corresponding row (based on name) in b.
Previous Topic: How to generate RANDOM Number in Oracle
Next Topic: Access to Oracle sql conversion
Goto Forum:
  


Current Time: Thu Apr 25 08:52:23 CDT 2024