On Sun, 11 Sep 2011 04:42:37 -0700 (PDT), liviodl
<[email protected]> wrote:

>
>Hi guys,
>
>I'm trying to create a multi-column unique constraint in SQLite, but I don't
>have success. In table "players", I've created the following index:
>
>    CREATE UNIQUE INDEX "players_unique" ON "players" ("id" ASC, "skill"
>ASC, "stagione" ASC, "settimana" ASC)
>
>When I issue the following commands, I see that a single row is create and
>then updated, even if I was hoping to obtain two different rows:
>
>    INSERT OR REPLACE INTO "players"
>(id,skill,e,f,s,r,a,g,p,w,c,stagione,settimana,v) VALUES
>("100","187","1","1","1","1","50","0","1","1","1","20","1","2011-09-05");
>
>    INSERT OR REPLACE INTO "players"
>(id,skill,e,f,s,r,a,g,p,w,c,stagione,settimana,v) VALUES
>("100","187","1","1","1","1","50","0","1","1","1","20","2","2011-09-05");
>
>The two INSERT rows are identical except the value under "settimana". I
>expected to not have a conflict, so that an INSERT should be performed for
>both the commands, but at the end I have only one row with settimana=2.
>
>Do you know why?

The other guys already answered the core of your question, 
I just want to add two sidenotes:

- String literals should be single quoted.
  Double quotes are used to be able to use reserved
  words as identifiers.

- Many of your columns seem to contain integers.
  Integer literals should not be quoted at all.

In many cases it doesn't make any difference, but one day you'll
bump into unexpected results or hard to explain errors.
-- 
  (  Kees Nuyt
  )
c[_]
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to