Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. SELECT FORMAT(SUM(data_length+index_length)/POWER(1024,3),2) InnoDB_DiskSpace
  2. FROM information_schema.tables
  3. WHERE engine='InnoDB';
  4.  
  5. SELECT
  6. IFNULL(tbl,'Total') table_name,
  7. FORMAT(SUM(table_bytes)/POWER(1024,3),2) table_size
  8. FROM
  9. (
  10. SELECT table_name tbl,SUM(data_length+index_length)table_bytes
  11. FROM information_schema.tables WHERE table_schema='mydb
  12. GROUP BY table_name WITH ROLLUP
  13. ) A ORDER BY ISNULL(tbl) DESC,table_bytes;
  14.  
  15. SELECT FORMAT(SUM(data_length+index_length)/POWER(1024,3),2) Table_Diskspace
  16. FROM information_schema.tables
  17. WHERE table_schema='mydb;
  18. AND table_name='mytable';
  19.  
  20. use mydb
  21. CREATE TABLE mytable_new LIKE mytable;
  22. INSERT INTO mytable_new SELECT * FROM mytable;
  23. ANALYZE TABLE mytable_new;
  24. SELECT FORMAT(SUM(data_length+index_length)/POWER(1024,3),2) Table_Diskspace
  25. FROM information_schema.tables
  26. WHERE table_schema='mydb;
  27. AND table_name='mytable_new';
  28. #
  29. # Stop Here. If you are happy with the size, do the last two commands
  30. # If you prefer, drop table mytable_new and do do the online schema change
  31. #
  32. RENAME TABLE mytable TO mytable_old,mytable_newTO mytable;
  33. DROP TABLE mytable_old;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement