Find Abandoned Tables

March 2, 2010

Some times it’s the simple function that helps.

This simple query will give return tables that haven’t be updated in over a year.  They are most likely.  Each should be reviewed to be dropped or converted into a compressed archive table.

USE information_schema;
SELECT TABLE_SCHEMA,
    TABLE_NAME,
    TABLE_ROWS,
    CREATE_TIME,
    UPDATE_TIME
FROM `TABLES`
    WHERE (TABLE_SCHEMA != "information_schema")
        AND (TABLE_SCHEMA != "mysql")
        AND (UPDATE_TIME < ADDDATE(NOW(), -365))
ORDER BY Table_Schema, update_time;

Tweet

tags: , , ,
posted in Commentary by mark

Follow comments via the RSS Feed | Leave a comment | Trackback URL

Leave Your Comment

 



Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org
Creative Commons License
MySQL Fan Boy by Mark Grennan is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.
HOME