On 8/22/2011 12:42 PM, Black, Michael (IS) wrote:
> autoincrement does keep order regardless of deletes.  rowid won't guarantee 
> it.
>
>
>
> So you don't "have" to add your own unless you need more than autoincrement.
>
>
>
> sqlite>  create table t1(id integer primary key,data text);
> sqlite>  insert into t1 values(NULL,'one');
> sqlite>  insert into t1 values(NULL,'two');
> sqlite>  insert into t1 values(NULL,'three');
> sqlite>  select rowid from t1 where rowid=(select max(rowid) from t1);
> 3
> sqlite>  delete from t1 where data='two';
> sqlite>  insert into t1 values(NULL,'two');
> sqlite>  select rowid from t1 where rowid=(select max(rowid) from t1);
> 4
>
>
>
> You'll always get the "last" record that was successfully inserted.

sqlite> insert into t1 values(2, 'another two');
sqlite> select rowid from t1 where rowid=(select max(rowid) from t1);
4

It seems that the record your statement returns is not the record that 
was successfully inserted most recently.
-- 
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to