Script need for dropping databases

2011-11-18 Thread a bv
Hi,
I have a linux box running mysql plus  phpmyadmin  which has tables
getting montly data and when a new month starts a new table is
created. I want to store only 2 years of data  so when a new month
starts  i need to drop the table which became the data container of 2
years previous data. So to make this job auto, i need a linux/mysql
script which will run on cron etc . Can you please help me
for a correct script ? (i cant say im a database guy :-)


Regards

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: Script need for dropping databases

2011-11-18 Thread Mohan L
On Fri, Nov 18, 2011 at 1:32 PM, a bv vbavbal...@gmail.com wrote:

 Hi,
 I have a linux box running mysql plus  phpmyadmin  which has tables
 getting montly data and when a new month starts a new table is
 created. I want to store only 2 years of data  so when a new month
 starts  i need to drop the table which became the data container of 2
 years previous data. So to make this job auto, i need a linux/mysql
 script which will run on cron etc . Can you please help me
 for a correct script ? (i cant say im a database guy :-)

 It may help :
http://www.cyberciti.biz/faq/how-do-i-empty-mysql-database/

and you can also use something like :

#!/bin/bash
mysql dbnaneEOFMYSQL
DROP table table_name;
CREATE TABLE table_name;
EOFMYSQL

Thanks  Rg
Mohan L


Re: Script need for dropping databases

2011-11-18 Thread Nuno Tavares
Hi unknown,

Have a look at database information_schema.TABLES:

SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA='database';

As long as your MySQL version is = 5.1, you don't need a cron script,
you can use the MySQL scheduler, create a stored procedure that will run
each month. You'll need to use prepared statements, something like this:

http://gpshumano.blogs.dri.pt/2009/09/06/automatically-cleaning-up-spam-wordpress-comments/



-NT

Em 18-11-2011 08:02, a bv escreveu:
 Hi,
 I have a linux box running mysql plus  phpmyadmin  which has tables
 getting montly data and when a new month starts a new table is
 created. I want to store only 2 years of data  so when a new month
 starts  i need to drop the table which became the data container of 2
 years previous data. So to make this job auto, i need a linux/mysql
 script which will run on cron etc . Can you please help me
 for a correct script ? (i cant say im a database guy :-)
 
 
 Regards
 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org