That is not quite correct Simon.  INTEGER PRIMARY KEY is always "auto 
incrementing" in that a new key is always one larger than the current max() key 
in the table.  However, INTEGER PRIMARY KEY AUTOINCREMENT means that the key is 
always one larger than *any key that has ever existed* in the table.

In other words, INTEGER PRIMARY KEY AUTOINCREMENT keys are uniquely ascending 
and will never be re-used.  Without AUTOINCREMENT the key may be re-used. On a 
"different" record.


---
()  ascii ribbon campaign against html e-mail
/\  www.asciiribbon.org

> -----Original Message-----
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
> boun...@sqlite.org] On Behalf Of Simon Slavin
> Sent: Friday, 03 August, 2012 10:00
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] AUTO_INCREMENT error
> 
> 
> On 3 Aug 2012, at 4:53pm, Brandon Pimenta <brandonskypime...@gmail.com>
> wrote:
> 
> > When using the SQL query
> >
> > CREATE TABLE test (
> > test_1 INTEGER PRIMARY KEY NOT NULL AUTOINCREMENT
> > );
> >
> > or
> >
> > CREATE TABLE test (
> > test_1 INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT
> > );
> >
> > I will get the same error.
> 
> All INTEGER PRIMARY KEY columns automatically have AUTOINCREMENT.  You should
> not specify it yourself.
> 
> Also, SQLite will never itself assign a NULL to any of the values.  Though I
> can see that you might want NOT NULL in there to stop it being done by a
> program which assigns its own value to test_1.
> 
> Simon.
> _______________________________________________
> 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

Reply via email to