Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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 studying the Monastery: (3)
As of 2024-03-19 11:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found