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!

Query For delete a table if exist

palkodiMay 18 2018 — edited May 18 2018

I have two large tables of data in production

create table ter (acc varchar2(30), key number, year number );

create table ter1 (acc varchar2(30), key number, year number);

  insert into ter values('1243', 000, 2018);

insert into ter1 values('1243', 001,2018);

insert into ter values('1244', 002,2018);

insert into ter1 values('1244', 002,2018);

insert into ter1 values('1245', 004,2018);

so if in ter the acc does not exist i want to delete  for current fiscal year from ter1 .. I jus need to delete for current fiscal year

so this is what I tried

delete from ter1 a  where not exist (select 1 from ter b where a.key = b.key and year =2018 )

is this the right way I am doing it ? I am not sure please help

This post has been answered by Frank Kulash on May 18 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 15 2018
Added on May 18 2018
1 comment
274 views