Recommanded Free YOUTUBE Lecture: <% selectedImage[1] %>

auto increment

2.x 버전

mysql은 autoincrement 필드를 지원한다. 그렇지만 sqlite(2.x 버전 기준)는 지원하지 않는다.

SQLite는 rowid로 물리적인 레코드 번호를 알아낼 수 있다. 그러므로 단순히 autoincrement용으로 사용할 거라면 rowid로도 충분하다.

select rowid, myage from mytest;
select * from mytest where rowid=1;

query로 해결하는 방법도 있긴하다.
create table t1(a integer primary key, b); 
insert into t1 values((select max(a) from t1)+1, 234); 

3.x 버전

  • 3.0 버전에서 지원하는지 확인해 봐야 할것 같음 - 2010/2/5