In my SQLite database table I have unique id for each row and have rows name sequentially, like 5 rows in table and having id 0 to 4 for each row.
now, when I remove any row from table like row number 3, this occurs a 'hole' and afterwards I add more data on table but the 'hole' is still exists.
Please tell me that is this important for me to know exact number of row and to have at every row data in order to access my table arbitrarily.
Is there any way in SQLite to do that, and can manage manually to remove and add data.
Adding or Removing objects from SQLite in iOS.
1246
28-Dec-2015
Updated on 28-Dec-2015
Tarun Kumar
28-Dec-2015In my knowledge primary keys of database table usually should not change through the lifetime of the row. So, we can find the total number of rows by running:
Now, create a TRIGGER for that table, whenever a delete creates a hole it will 'roll down' according to ID number:
I hope above example will solve your problem.