Juvette M
Juvette M

Reputation: 51

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

Upvotes: 1

Views: 5868

Answers (2)

Omari Victor Omosa
Omari Victor Omosa

Reputation: 2879

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'))

Upvotes: -1

snehal gugale
snehal gugale

Reputation: 156

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

Upvotes: 2

Related Questions