Post Pacific  

Go Back   Post Pacific > Lineage 2 > Lineage 2 Server Modifications ONLY!
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 06.03.2007, 08:47   #1
srh
Архивный участник
 
Join Date: Aug 2005
Posts: 145
Default [share] sql. cleanup deleted chars.

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
if someone know how to clean up pet_data this will be nice.
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
srh is offline  
Old 06.03.2007, 09:00   #2
mcrabben7
Архивный участник
 
Join Date: Apr 2006
Posts: 461
Default

Nice share. This is a pretty useful script. Good job.
mcrabben7 is offline  
Old 06.03.2007, 09:05   #3
Mio
Архивный участник
 
Join Date: Feb 2007
Posts: 202
Default

Nice share. Thank you.
Mio is offline  
Old 06.03.2007, 09:22   #4
l2serverfull
Архивный участник
 
Join Date: Sep 2006
Posts: 64
Default

nicee thxx lott
l2serverfull is offline  
Old 06.03.2007, 12:01   #5
Rexx
Архивный участник
 
Join Date: Jun 2006
Posts: 64
Default

Thanks for sharing, very useful.
Rexx is offline  
Old 06.03.2007, 18:31   #6
URANUS
Архивный участник
 
Join Date: Jul 2006
Posts: 69
Default

Good work ^_^
URANUS is offline  
Old 06.03.2007, 19:48   #7
hr
Архивный участник
 
Join Date: Jun 2005
Posts: 285
Default

Quote:
if someone know how to clean up pet_data this will be nice.
comments/suggestions are welcome.
haven't tested, but maybe so:
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);
--or--

2) after item deletion
Code:
delete from pet_data where pet_id not in (select item_id from user_item);
ps: btw your item deletion is wrong. it may delete some pledges' items. this one more correct:

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);
pps: better use user_deleted table to get info about deleted chars
hr is offline  
Old 07.03.2007, 04:03   #8
DR!VER
Архивный участник
 
Join Date: Nov 2006
Posts: 49
Default

Thanks, nice share
DR!VER is offline  
Old 07.03.2007, 04:54   #9
srh
Архивный участник
 
Join Date: Aug 2005
Posts: 145
Default

Quote:
Originally Posted by hr View Post
pps: better use user_deleted table to get info about deleted chars
sometimes chars get deleted not from game
srh is offline  
Old 07.03.2007, 07:48   #10
hr
Архивный участник
 
Join Date: Jun 2005
Posts: 285
Default

if u use cached it also puts info into user_deleted
hr is offline  
Old 07.03.2007, 09:33   #11
JotaC
Архивный участник
 
Join Date: Mar 2006
Posts: 69
Default

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 ^^
JotaC is offline  
Old 08.03.2007, 05:40   #12
DevilsAssociate
Архивный участник
 
Join Date: Jul 2006
Posts: 81
Default

nice really usefull good job
DevilsAssociate is offline  
Old 08.03.2007, 09:19   #13
GmZenBrasil
Архивный участник
 
Join Date: Jan 2007
Posts: 30
Default

Good job man, thanks, very good share ^^
GmZenBrasil is offline  
Old 09.03.2007, 18:08   #14
yokohiro
Архивный участник
 
Join Date: Jan 2007
Posts: 18
Default

nice really usefull good job. very good share.. thx man
yokohiro is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 23:36.