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!

Copy only new data from one table to another

learningoracleMay 15 2006 — edited May 16 2006
Table 1
Name Class
-------- -------
John A
Peter B -- data comes in second day.

Table 2
Name Class Flag
-------- ------- -------
John A Y

I have two tables. Everyday, new records will be inserted into Table 1. At the begninning of the week, i will select data from Table 2(based on some rules) and process them Those that are processed are marked Y under flag. So each time i'll just
 select * from table 2 where flag1 is null and <more conditions> 
to run my process. My problem is how can i only select data from table 1 and are not in table 2 and copy them into Table 2. I cannot truncate Table 2 and copy from Table 1 each time, because i cannot process the same data again. i.e how can i only copy Peter from Table 1 without affecting John in Table 2.

I thought of this
 insert into Table 2 
select * from Table 1 where Table1.Name not in Table2;
I believe this is wrong, any advise?

Message was edited by:
learningoracle
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 13 2006
Added on May 15 2006
7 comments
1,352 views