Written by:David Aldridge2/18/2011 2:42 PM
The simplest answer to this is to restore a backup of the database. If however you don't have one then this is how to clean up the database.
The core of the database resides in four tables - user, revision, page and text. Revision can be considered the core of the core, as the others link through it to relate to one another. Users create revisions which have a page and text associated with them. To find all of the pages and revisions created by a user, you can use the following SQL commands:select user_id from user where user_email='a@b.com'; This will give you the internal user_id number referenced in the revision, page and text tables to allow you to remove what that user added. First remove the text:delete from text where old_id in (select rev_text_id from revision where rev_user=user_id); Where user_id is the one you got from the select statement above. Then remove the pages:delete from page where page_id in (select rev_page from revision where rev_user=user_id); Now remove the revisions:delete from revision where rev_user=user_id; And finally remove the user themselves:delete from user where user_id=user_id;
select user_id from user where user_email='a@b.com';
delete from text where old_id in (select rev_text_id from revision where rev_user=user_id);
delete from page where page_id in (select rev_page from revision where rev_user=user_id);
delete from revision where rev_user=user_id;
delete from user where user_id=user_id;
0 comment(s) so far...