Hi Alex,

On Thu, 18 Jul 2019 at 17:02, Alexandre Billon <a.bil...@bert.fr> wrote:
>
> Hello,
>
> I have created a table.
>
>         CREATE TABLE "sales" (
>                 "client"        TEXT,
>                 "salesman"      TEXT,
>                 "revenue"       REAL,
>                 PRIMARY KEY("client","salesman")
>         );
>
> I can run the query below mutliple times without any error :
>
>         INSERT INTO sales ("client", "salesman", "revenue")
>         VALUES ('C1', NULL, 10.0);
>
> Have I missed something in the CREATE instruction ?
> Is this a normal behaviour ?
>
> I have tried to read https://sqlite.org/lang_createtable.html#constraints and 
> https://www.sqlite.org/nulls.html but I don't really have found why I can 
> insert 2 records that have the same primary key.

You quote "https://sqlite.org/lang_createtable.html#constraints";,
which contains:
<<
Each row in a table with a primary key must have a unique combination
of values in its primary key columns. For the purposes of determining
the uniqueness of primary key values, NULL values are considered
distinct from all other values, including other NULLs.
>>

I.e the rows you are inserting do not have conflicting primary keys

The paragraph following the one quoted above is also relevant...

> Thanks in advance for your insights.
>
> Alex

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

Reply via email to