Autmatically create table on MySQL server based on date?

Posted by Anthony on Stack Overflow See other posts from Stack Overflow or by Anthony
Published on 2010-01-04T18:55:18Z Indexed on 2010/03/09 11:51 UTC
Read the original article Hit count: 289

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:

  1. 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?

  2. What are the potential problems with my home-grown method I originally thought up?

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql