MySQL Forums
Forum List  »  Italian

Problem delete a row wit ha script
Posted by: Sam Zorro
Date: August 12, 2010 07:44AM

Hi guys!

i have to implement a procedure for purge daily a table of a database.

The script works correctly from phpmyadmin ... logged like root.

DELETE FROM snmptt WHERE traptime < date_add(sysdate(), interval -7 day);

The database is use for store tha trap snmp connected to nagios (SNMPTT).

My idea is purge daily the db and mantain the last week records.

The problem is that when i run the script i obtain this error :

SCRIPT :

# delete records older than 7 days
use snmpttdslam;
DELETE FROM snmptt WHERE traptime < date_add(sysdate(), interval -7 day);
OPTIMIZE TABLE `snmptt`;
exit

ERROR :

Delete records old more than one week snmptt tables from snmpttdslam database...
ERROR 1175 (HY000) at line 1: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
+--------------------+----------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+--------------------+----------+----------+----------+
| snmpttdslam.snmptt | optimize | status | OK |
+--------------------+----------+----------+----------+

I can't change the primary key in the db ... so ... what can i do?

please provide me more info!

thanks

sam

Options: ReplyQuote


Subject
Views
Written By
Posted
Problem delete a row wit ha script
3405
August 12, 2010 07:44AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.