On Thu, Oct 14, 2010 at 10:54 AM, Kavita Raghunathan
<kavita.raghunat...@skyfiber.com> wrote:
> 3. How can I make my primary ID remain sequential even after a delete of row. 
> Can sqlite somehow realign the indices after a row in the middle is deleted ?
>

If you can change the "primary ID" (sic), by which, I am assuming you
are referring to the primary key, then it won't really be the primary
key. PK should be immutable.

Create a separate ID that can be under your control, and change it as you wish.

>
> On 10/14/10 10:53 AM, "Kavita Raghunathan" <kavita.raghunat...@skyfiber.com> 
> wrote:
>
> Hello,
> I’ve been adding and deleting rows from the sqlite database. Now the primary 
> ID is non-sequential.
>
>
>  1.  How do I get the nth entry in the database
>  2.  AND, How do I get the first n rows from the database ?
>

Both "nth" and "first n" depend upon the sort order. Sort the table
the way you want, and then get the nth or the first n (use
LIMIT/OFFSET) to get the desired rows.

The db by itself has no sort order, although, if you have numeric PK,
there is an implicit ascending sort on PK.

>
> Thanks,
> Kavita
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to