Reputation: 1820
I have a table in SQLite and I want to have exactly 50 entries, not more. There can be less. The list should be work as FIFO. So I add an entry always at position id=1. If the list exceed the size of 50, the entry with id=51 will be removed. How can I do this?
id | entry
---------------
1 First
2 Second
. .....
50 Fiftieth
add a new entry:
id | entry
---------------
1 NewFirst
2 First
3 Second
. .....
50 Fourtynineth
Upvotes: 0
Views: 858
Reputation: 1294
You could use a trigger for that. It will do a specific task every time you make an update, insert or delete.
CREATE TRIGGER trigger_name [BEFORE|AFTER] event_type (insert,update,delete) ON table_name BEGIN -- Trigger logic END;
Take a look at this site: http://www.tutorialspoint.com/sqlite/sqlite_triggers.htm
Upvotes: 1