On 18 Jul 2019, at 5:02pm, Alexandre Billon <a.bil...@bert.fr> wrote:

>       INSERT INTO sales ("client", "salesman", "revenue")
>       VALUES ('C1', NULL, 10.0);

The value NULL in SQLite means 'value unknown'.  It is a special case.  If you 
compare two NULLs SQLite will act as if those values are different.  Therefore 
you can have two PRIMARY KEYs with NULL in the same place.

<https://www.sqlite.org/nulls.html>

> sqlite> INSERT INTO sales ("client", "salesman", "revenue")
>          ...> VALUES ('C1', '', 10.0);
> sqlite>
> sqlite> INSERT INTO sales ("client", "salesman", "revenue")
>          ...> VALUES ('C1', '', 10.0);
> Error: UNIQUE constraint failed: sales.client, sales.salesman

As you see here when you try the sme thing with non-NULL values, you get the 
error you expected.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to