Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Deleting Old Files in a DB.

by benn (Priest)
on Oct 09, 2003 at 11:41 UTC ( #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.


Comment on Re: Deleting Old Files in a DB.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2014-09-02 02:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (18 votes), past polls