Reputation: 353
How could I delete all the rows after the 20th in sqlite, in another way I need to maintain a database with only 20 rows at each new insert I need to delete the oldest row inserted
Upvotes: 1
Views: 53
Reputation: 23374
DELETE FROM stuff
WHERE rowid NOT IN (
SELECT rowid FROM stuff ORDER BY created DESC LIMIT 20);
See http://sqlfiddle.com/#!7/a3e2f/9
Upvotes: 3