That's because my id is autoincrement and yours is not.
Michael D. Black Senior Scientist NG Information Systems Advanced Analytics Directorate ________________________________ From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of Igor Tandetnik [itandet...@mvps.org] Sent: Monday, August 22, 2011 12:18 PM To: sqlite-users@sqlite.org Subject: EXT :Re: [sqlite] Last record in db On 8/22/2011 1:11 PM, Black, Michael (IS) wrote: > Sure it does. > > sqlite> select rowid,id,* from t1 where id=(select max(id) from t1); > 4|4|4|two > > > > "two" was the last succesful insert in my example. But 'another two' (id==2) was the last successful insert in my extension of your example. Yet your statement still returns 4. > I'm now noticing though that rowid is not working as documented. > > http://www.sqlite.org/autoinc.html > > Says "If no ROWID is specified on the insert, or if the specified > ROWID has a value of NULL, then an appropriate ROWID is created > automatically. The usual algorithm is to give the newly created row a > ROWID that is one larger than the largest ROWID in the table prior to > the insert." > > But....if I delete the max rowid I expect it to be re-used based on the > above.... The quote you cite applies to the case where AUTOINCREMENT keyword is not specified. But in your latest example, you do specify one. -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users