Deleting 100 rows which meets certain criteria

From: shulkae <shulkae(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Deleting 100 rows which meets certain criteria
Date: 2009-12-30 17:11:34
Message-ID: 1edeb9e0-d8d4-45bc-9794-cba6d6891e14@j24g2000yqa.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am newbie to postgres/SQL.

I want to delete all rows exceeding 400 hours (10 days) and I want to
limit deletion of only 100 records at a time.

I was trying the following in PostgreSQL:

DELETE from mytable WHERE (now() - timestamp_field > INTERVAL '400
hour' ) LIMIT 100;

Looks like DELETE syntax doesn't support LIMIT.

Is there any other way to achieve this?

thanks
Shul

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gastón Quiroga 2009-12-30 18:07:01 Re: pg_dump ERROR, usename "postgres" duplicated
Previous Message Nicola Farina 2009-12-30 16:10:30 Re: Out of memory problem