On Mon, Apr 21, 2014 at 1:15 PM, Neville Dastur <nevillebdas...@gmail.com>wrote:

>
> On 21 Apr 2014, at 18:13, Andy Goth <andrew.m.g...@gmail.com> wrote:
>
> > On 4/21/2014 6:04 AM, Richard Hipp wrote:
> >> On Mon, Apr 21, 2014 at 6:18 AM, Neville Dastur wrote:
> >>> Google only showed up that UNIQUE needs to be added regardless of the
> >>> column being a PRIMARY KEY.
> >>
> >> Google is wrong.  The UNIQUE is superfluous.  PRIMARY KEY always
> >> implies UNIQUE.  Always.
> >
> > PRIMARY KEY also is supposed to imply NOT NULL.  However, for historical
> > reasons, SQLite allows NULL in PRIMARY KEY columns if the column is not
> > INTEGER, not explicitly NOT NULL, and not in a WITHOUT ROWID table.
>
> Does that mean that I should really explicitly state NOT NULL for
> non-integer primary keys?
>

Yes.

SQLite does the right thing and enforces NOT NULL on PRIMARY KEY for the
newer WITHOUT ROWID tables.  But long ago there was a bug that prevented
enforcement NOT NULL on PRIMARY KEY of ordinary tables and by the time the
bug was discovered we couldn't really fix it without breaking lots of
legacy.

-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to