-1

I have one SQLite table. I want it to store only 1000 rows maximum.

If a new record comes aftre that limit, then it should automatically delete the last row before inserting the new one.

Is there any way to achieve this?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0

Check before you insert

Your command should be like this...

if ((select count(*) from yourTable)=1000)
   delete from yourTable where id= (select max(id) from yourTable)
   insert into yourTable values(@values...)
else
   insert into yourTable values(@values...)
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Sankar
  • 6,908
  • 2
  • 30
  • 53