Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / January 2006

Tip: Looking for answers? Try searching our database.

Auto delete rows older than a month

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve - 17 Jan 2006 22:09 GMT
delete from MYTABLE where date(MYCOLUMN) = current date - 30

"MYCOLUMN" is of type timestamp.

This query doesnt' work. Anything I missed here? I am hoping to
automate it on a daily basis. Anyone knows a better way to do it? Much
appreciated.
Knut Stolze - 17 Jan 2006 22:12 GMT
> delete from MYTABLE where date(MYCOLUMN) = current date - 30
>
[quoted text clipped - 3 lines]
> automate it on a daily basis. Anyone knows a better way to do it? Much
> appreciated.

You probably meant:

delete from MYTABLE where date(MYCOLUMN) = current date - 30 DAYS

Signature

Knut Stolze
DB2 Information Integration Development
IBM Germany

Gert van der Kooij - 17 Jan 2006 22:22 GMT
> delete from MYTABLE where date(MYCOLUMN) = current date - 30
>
[quoted text clipped - 3 lines]
> automate it on a daily basis. Anyone knows a better way to do it? Much
> appreciated.

delete from MYTABLE where date(MYCOLUMN) = current date - 30 days
bughunter@ru - 18 Jan 2006 06:49 GMT
where date(MYCOLUMN) = current date - 30 DAYS

But this query will be not optimal, because it will be indexscan by
mycolumn index.

If query is long rewrite it like

where MYCOLUMN >= timestamp(current date - 30 DAYS,'00:00')  and
MYCOLUMN < timestamp(current date - 29 DAYS,'00:00')

Andy

> delete from MYTABLE where date(MYCOLUMN) = current date - 30
>
[quoted text clipped - 3 lines]
> automate it on a daily basis. Anyone knows a better way to do it? Much
> appreciated.
Steve - 19 Jan 2006 22:45 GMT
"current date - 30 days" does what I need. Thanks a lot!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.