简体   繁体   中英

how do i delete records older than 90 days from a table in postgres

Please I have a very large table that store historical data and I want a query that can help me to delete rows/records that are older than 90 days on that table

delete from table_name
where timestamp_column < now() - interval '90 days'

enclose the (now() - interval '90 days'))

select (now() - interval '90 days'))

bodmas can apply here. hence without enclosing you may get wrong result, use below

delete from table_name where timestamp_column < (now() - interval '90 days'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM