Autmatically create table on MySQL server based on date?
- by Anthony
Is there an equivalent to cron for MySQL?
I have a PHP script that queries a table based on the month and year, like:
SELECT * FROM data_2010_1
What I have been doing until now is, every time the script executes it does a query for the table, and if it exists, does the work, if it doesn't it creates the table.
I was wondering if I can just set something up on the MySQL server itself that will create the table (based on a default table) at the stroke of midnight on the first of the month.
Update
Based on the comments I've gotten, I'm thinking this isn't the best way to achieve my goal. So here's two more questions:
If I have a table with thousands of rows added monthly, is this potentially a drag on resources? If so, what is the best way to partition this table, since the above is verboten?
What are the potential problems with my home-grown method I originally thought up?