MySQL Forums
Forum List  »  General

Re: Delete from all tables
Posted by: Rick James
Date: January 18, 2014 03:14PM

It is possible to write a stored procedure that would walk through (using a cursor) information_schema.TABLES to find all the TABLE_NAMEs. For each name, build (using "concat" and "prepare") each DELETE statement, then EXECUTE it.

But why have 5500 tables? That smells like poor schema design, especially if they are similar enough to have the same column.

Note: If your database grows to, say, 55K tables, performance will be bad -- because the Operating System can't deal with lots of files in a single directory. MySQL implementation: One database = one directory; one table = 1-3 files.

If `xxx` is a date, and this DELETE is to purge old data, then let's talk about PARTITIONing on RANGE and using DROP PARTITION instead of DELETE. If both are practical for your app (5500->1 and time-based purging), we can talk about how to make both conversions at the same time.

Options: ReplyQuote


Subject
Written By
Posted
January 17, 2014 01:39PM
Re: Delete from all tables
January 18, 2014 03:14PM
January 18, 2014 04:22PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.