Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Deleting Old Files in a DB.

by benn (Vicar)
on Oct 09, 2003 at 11:41 UTC ( [id://297880]=note: print w/replies, xml ) Need Help??


in reply to Deleting Old Files in a DB.

If you're looking for a way of deleting old *records* from an SQL-based DBMS, then you can usually do this with pure SQL (and thus in any language you like that provides DB connections), assuming that you stored the original record-creation time (rec_timestamp, in the example below).

Therefore, a simple Perl program to do this with MYSQL would look something like...

use DBI; my $dbh = DBI->connect("DBI:mysql:db_name","user","pass") || die $DBI: +:err; $dbh->do("delete from mytable where to_days(rec_timestamp) < to_days(n +ow()) - 90");
HTH, Ben.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://297880]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2025-02-08 04:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (95 votes). Check out past polls.