422,026 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,026 IT Pros & Developers. It's quick & easy.

Move data from current table to history db2 table

P: 2
There are 2 tables -current and history table.I have to move data from current table to history table and after moving current table data should be deleted.(There should be roll back and commit handling as well)
Jan 11 '18 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 875
if your unique id is 'id'

Copy everything from current to history:
insert into history select * from current where id not in (select id from history)

Delete everything from current that is in history:
delete from current where id in (select id from history)
Jan 13 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.