Move data from current table to history db2 table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sdhar
    New Member
    • Jan 2018
    • 2

    Move data from current table to history db2 table

    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)
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    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)

    Comment

    Working...