Advertisement
Mlie

MYSQL, Savepoint & Truncate

Oct 15th, 2014
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.57 KB | None | 0 0
  1. -- 1. UPDATE TABLE "world"
  2.  
  3. UPDATE world set code = 1 WHERE lang = 'kor';
  4.  
  5. -- 2. SET SAVEPOINT
  6.  
  7. SAVEPOINT kr;
  8.  
  9. -- 3. DELETE FROM world
  10.  
  11. DELETE FROM world WHERE lang = 'kor';
  12.  
  13. -- 4. Rollback to kr
  14.  
  15. ROLLBACK TO kr;
  16.  
  17. -- BONUS 1. TRUNCATE : DELETE TABLE's ALL row.
  18.  
  19. truncate table world;
  20.  
  21. -- BONUS 2. ROLLBACK
  22.  
  23. rollback;
  24.  
  25. -- BONUS 3. LOOK TABLE "world"
  26.  
  27. SELECT * FROM world;
  28.  
  29. -- Empty set.
  30. -- TRUNCATE can not recovery.
  31.  
  32. -- Yeungnam University College // Cyber Security [2014] //
  33. -- homepage: http://www.ync.ac.kr/
  34. -- blog: http://namedit.tistory.com/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement