Question

I need to delete all tables that were created today. I do not know what are the tables., because the process is autogenerated by a framework.

This is possible by querying information_schema? any idea?

Was it helpful?

Solution

You can get all tables created today by using

SELECT TABLE_NAME, TABLE_SCHEMA AS db FROM information_schema.`TABLES` t 
WHERE DATE(t.CREATE_TIME) = CURDATE() 
AND t.TABLE_SCHEMA NOT IN("information_schema", "mysql", "performance_schema")

The NOT IN("information_schema", "mysql", "performance_schema") excludes (temporary) system tables created by msql itself. It's best to limit TABLE_SCHEMA to whatever database name you are using, if you don't need to delete tables among different databases.

How you delete them is now up to you ;).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top