Last active
August 29, 2015 14:03
-
-
Save gjaya79/79f45cba37371d8b8a67 to your computer and use it in GitHub Desktop.
MYSQL SPECIAL QUERY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show the database sizes: | |
SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" | |
FROM information_schema.TABLES GROUP BY table_schema ; | |
Show table sizes | |
SELECT TABLE_NAME "Table Name", (data_length + index_length) / 1024 / 1024 "Table Size in MB", TABLE_ROWS "Number of row(s)" | |
FROM information_schema.TABLES where TABLE_SCHEMA=''; | |
Delete rows which are 180 days older; | |
DELETE FROM apihistory | |
WHERE timestamp < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 180 DAY)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment