![]() |
|
|
#1 |
|
Архивный участник
Join Date: Aug 2005
Posts: 145
|
this code cleanup database after char get deleted.
before use any script - backup your db ![]() Code:
begin tran delete from bookmark where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from nobless_achievements where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from olympiad_match where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from olympiad_result where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from Quest where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from shortcut_data where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from ssq_user_data where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_ActiveSkill where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_ban where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_blocklist where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_comment where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_deleted where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_friend where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_henna where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_history where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_item where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_log where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_macroinfo where macro_id in (SELECT macro_id FROM user_macro WHERE char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1))); delete from user_macro where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_mail where id in (SELECT mail_id FROM user_mail_receiver WHERE receiver_id in (select char_id from user_data where (account_id = - 1))); delete from user_mail where id in (SELECT mail_id FROM user_mail_sender WHERE sender_id in (select char_id from user_data where (account_id = - 1))); delete from user_mail_receiver where receiver_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_mail_sender where sender_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_newbie where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_nobless where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_punish where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_recipe where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_skill where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_sociality where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_subjob where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete from user_surrender where char_id in (SELECT char_id FROM user_data WHERE (account_id = - 1)); delete FROM user_data WHERE (account_id = - 1); commit comments/suggestions are welcome. if u need to delete accounts that not used in 180 days change (account_id = -1) to (login < GETDATE() - 180) in next script we cleanup accounts that do not have any char
|
|
|
|
|
#2 |
|
Архивный участник
Join Date: Apr 2006
Posts: 461
|
Nice share. This is a pretty useful script. Good job.
|
|
|
|
|
#3 |
|
Архивный участник
Join Date: Feb 2007
Posts: 202
|
Nice share. Thank you.
|
|
|
|
|
#4 |
|
Архивный участник
Join Date: Sep 2006
Posts: 64
|
nicee thxx lott
|
|
|
|
|
#5 |
|
Архивный участник
Join Date: Jun 2006
Posts: 64
|
Thanks for sharing, very useful.
|
|
|
|
|
#6 |
|
Архивный участник
Join Date: Jul 2006
Posts: 69
|
Good work ^_^
|
|
|
|
|
#7 | |
|
Архивный участник
Join Date: Jun 2005
Posts: 285
|
Quote:
1) before item deletion Code:
delete from pet_data where pet_id in (select ui.item_id from user_item as ui left join user_data as ud on (ui.char_id=ud.char_id) where ud.account_id = - 1); 2) after item deletion Code:
delete from pet_data where pet_id not in (select item_id from user_item); Code:
delete from user_item where item_id in (select ui.item_id from user_item as ui left join user_data as ud on (ui.char_id=ud.char_id) where ud.account_id = - 1 and ui.warehouse<>2); |
|
|
|
|
|
#8 |
|
Архивный участник
Join Date: Nov 2006
Posts: 49
|
Thanks, nice share
|
|
|
|
|
#9 |
|
Архивный участник
Join Date: Aug 2005
Posts: 145
|
|
|
|
|
|
#10 |
|
Архивный участник
Join Date: Jun 2005
Posts: 285
|
if u use cached it also puts info into user_deleted
|
|
|
|
|
#11 |
|
Архивный участник
Join Date: Mar 2006
Posts: 69
|
good share, i am making one to change all valors bigger than 1 in database, and i mean in punishment table, to 1, since i am having some problems with clan times.. i will post it later it may be usefull to someone too ^^
|
|
|
|
|
#12 |
|
Архивный участник
Join Date: Jul 2006
Posts: 81
|
nice really usefull good job
|
|
|
|
|
#13 |
|
Архивный участник
Join Date: Jan 2007
Posts: 30
|
Good job man, thanks, very good share ^^
|
|
|
|
|
#14 |
|
Архивный участник
Join Date: Jan 2007
Posts: 18
|
nice really usefull good job. very good share.. thx man
|
|
|
|
|