beowulf1416

Untitled

Dec 1st, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. -- recreate log_mpe table
  2. create table log_mpe_2 like log_mpe;
  3.  
  4. -- insert last record in log_mpe to new log_mpe table
  5. insert into log_mpe_2
  6. select *
  7. from log_mpe l1
  8. where id = (
  9. select max(l2.id)
  10. from log_mpe l2
  11. );
  12.  
  13. -- rename table, subsequent inserts will go to new log_mpe table
  14. -- and use the next higher id
  15. rename table log_mpe to log_mpe_orig, log_mpe_2 to log_mpe;
  16.  
  17. -- insert remaining records from original log_mpe table
  18. insert into log_mpe
  19. select *
  20. from log_mpe_orig lo
  21. where id < (
  22. select min(lo.id)
  23. from log_mpe l1
  24. );
Advertisement
Add Comment
Please, Sign In to add comment