On Thursday, 18 May, 2017 10:17, Paul Sanderson <sandersonforens...@gmail.com> 
wrote:

> Create table test (id integer not null primary key, data text);
> insert into test values (null, 'row1');
> select * from test;
> 1, row1
 
> I know that if you provide a NULL value to a column define as integer
> primary key that SQLite will provide a rowid, but should the not null
> constraint be obeyed?

Specifying NOT NULL on an INTEGER PRIMARY KEY (which is an alias for the RowID) 
is a redundant redundancy.  The RowID cannot be null and must have a value.  
Trying to insert a null value is how you get one generated for you.  

It should probably be an error to specify "NULL" or "NOT NULL" (or anything 
else other than perhaps AUTOINCREMENT) with an INTEGER PRIMARY KEY (RowID 
alias).  However, rather than do so the redundant redundancies and the 
illogical declarations (such as INTEGER PRIMARY KEY NULL or COLLATE clauses) 
are merely silently ignored.




_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to