![]() |
|
|
#1 |
|
Архивный участник
Join Date: May 2005
Posts: 133
|
Hi,
I'm trying to make a cleanup script to delete accoutns from db that aren't used for like a month. I tried much out myself (some examples below) Can someone teach me how to use the correct commands. Tried to look for explanations on google but i didn't find any understandable explanations. Would be nice if someone can advice me on this one. Greetz DELETE FROM user_account WHERE last_logout < 20-8-2005 8:00:00 DELETE FROM user_account WHERE last_logout < 208200580000 DELETE FROM user_account where last_login = NULL |
|
|
|
|
#2 |
|
Архивный участник
Join Date: Aug 2005
Posts: 278
|
You basically have it, except data format is incorrect, try
Code:
DELETE FROM user_account WHERE last_logout < 20/08/2005 Code:
DELETE FROM user_account WHERE last_ip IS NULL P.S. sorry to pull the chain but, could you please pm me LDragon (Good thing :P) |
|
|
|
|
#3 |
|
Архивный участник
Join Date: Sep 2005
Posts: 408
|
don't forget to make note of the account numbers so you can delete the characters to go with it
the accounts take up very little.. the characters take up the most. especially the user_item
|
|
|
|
|
#4 |
|
Архивный участник
Join Date: May 2005
Posts: 133
|
Hi i want to thank you both for the nice reaction. :wink:
Now i only need to find out how to convert the time and date together in the script because the time and dae are like this in the db: "10-9-2005 17:28:4" Now i tried only the date but there are no rows affected when i do it like that so i must have the time too but i don't know how to describe the : symbol and in he db there seems to be a space between the date and time wich i can't define too. Greetz LdragonL |
|
|
|
|
#5 |
|
Архивный участник
Join Date: May 2005
Posts: 216
|
Before u delete any data from db like "DELETE FROM user_account WHERE last_ip IS NULL" think again.
there r also data refering to that account in other tables like ssn, user_auth, etc... I suggest u to do the script which will first check for crossreferences and than delete them all at once if u dont want to have buggy db. |
|
|
|
|
#6 | |
|
Архивный участник
Join Date: Aug 2005
Posts: 278
|
Quote:
|
|
|
|
|
|
#7 |
|
Архивный участник
Join Date: May 2005
Posts: 133
|
No the script doesn't work because in the db there is date with time. When we fill in only the date the script doesn't find any rows matching the script.
i just need to know wich symbol must be replaced in the script for this ":" like 12/4/2005 10:30:00 but the space between it is causing an error too in sql query manager :S |
|
|
|
|
#8 | |
|
Архивный участник
Join Date: May 2005
Posts: 315
|
Quote:
|
|
|
|
|
|
#9 |
|
Архивный участник
Join Date: May 2005
Posts: 133
|
Mm yes, it's not as easy as i thought.
But i keep working on it when i learn those darn sql db scripts. |
|
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|