How do I delete a fixed number of rows with sorting in PostgreSQL?

后端 未结 6 1505
予麋鹿
予麋鹿 2020-11-28 03:27

I\'m trying to port some old MySQL queries to PostgreSQL, but I\'m having trouble with this one:

DELETE FROM logtable ORDER BY timestamp LIMIT 10;

6条回答
  •  失恋的感觉
    2020-11-28 03:43

    You could write a procedure which loops over the delete for individual lines, the procedure could take a parameter to specify the number of items you want to delete. But that's a bit overkill compared to MySQL.

提交回复
热议问题