Page 1 of 1

php script for dropping tables.

Posted: Wed Apr 21, 2010 9:29 pm
by viziony
Hi all!

I am a beginner to php and also mysql. I have to do some maintenance on a database and I open to any suggestion / feedback you all can provide. I have a huge user table which also references user tables. Table "User" contains "User1" table , "User2" table, etc. I can query to give me results for users that have not logged in since January of 2010. How do I go about using the results to drop the tables ? Would this be easier via php script or mysql ? I cannot find a way to do this via mysql and I don't have a backup of my database since it has over 400k tables. And cannot seem to list the files within the database directory (or it would take a really long time). I need to do some cleanup and that is why I am asking

Thank you for reading and providing any valuable information!

Re: php script for dropping tables.

Posted: Wed Apr 21, 2010 10:18 pm
by requinix
First, your terminology. Tables have rows, not more tables. What you want are to delete rows that match a condition.
Also there aren't files in a database. You may be storing file contents in tables or you may be storing just the names.

To delete rows from a table in MySQL,

Code: Select all

DELETE FROM tablename WHERE condition
Your task is to figure out what the "condition" should be.

And what are you trying to "clean up"?