A stored procedure for assisting with database backups

You can use the following stored procedure to quickly clean up your MySQL database for when you want to do a backup. Just call it using the following SQL command: "call cleanforexport();"


CREATE PROCEDURE cleanforexport()
begin
delete from mt_log where log_category = 'straight_search';
delete from mt_log where log_message like 'news callback%';
delete from mt_session where session_id like 'blog::%';
delete from mt_comment where comment_junk_status < 0;
delete from mt_tbping where tbping_junk_status < 0;
delete from mt_asset where asset_label like 'Thumbnail%';
delete from mt_asset_meta where asset_meta_asset_id not in (select asset_id from mt_asset);
end

If you are using phpMyAdmin, the make sure that you set the delimiter field to use something other than ";" as the delimiter. // is a good example of an alternative.

Leave a comment

March 2010

Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Recent Entries

A window into the totalitarian mind of the left on freedom of religion
From Digg: Me: I'm not going to hold my breath waiting for the same liberal democrats who shriek about the…
Google's lossy compiler
Google's closure compiler service gets a little too frisky under ADVANCED_OPTIMIZATIONS. Original code: With advanced optimizations enabled, it was able…
The three purposes of the federal income tax law
Businesses will spend about 3.4 billion man-hours and individuals about 1.7 billion hours figuring out their taxes this year.…

Subscribe

Advertisements

OpenID accepted here Learn more about OpenID