On Fri, 28 Mar 2014 12:56:59 +0100, "Kleiner Werner" <sqliteh...@web.de> wrote:
> > >Hello >I saw some discussions here about using the word "AUTOINCREMENT" for a primary >key or not. > >Sometimes the meaning is "INTEGER PRIMARY KEY" is enough, because this will >also make an auto increment id. > >Can someone give me a clarification if "AUTOINCREMENT" is needed or not? >In the FAQ I can read this; >" The new key will be unique over all keys currently in the table, > but it might overlap with keys that have been previously deleted > from the table." > > Does this mean, if there are 10 rows with id 1 -10 > and I delete row with id 5, > then the next insert will be ID = 5? > Or is next ID = 11? The next ID will usually be 11, but it is not guaranteed. One day, it could suddenly be 5. > I understand that if I need absolutely unique IDs over > the lifetime I need to use AUTOINCREMENT. That's correct? That's correct. > And with AUTOINCREMENT the last IDs will be stored in a > table "sqlite_sequence"? Yes > Are there sow disatvantages of using AUTOINCREMENT , > like SQLite is slower or something else? It has to do a bit more, so it will be slightly slower, but not much. The sequence table is small and will be in the cache most of the time. If the sequence is updated, it will have to be flushed to disk at COMMIT TRANSACTION. I wouldn't worry about it unless you are in a very fast real-time environment. Premature optimization is the root of all evil. -- Groet, Cordialement, Pozdrawiam, Regards, Kees Nuyt _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users