Re: ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification

2018-05-05 Thread Alexander Farber
Thanks, now I see the difference

Re: ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification

2018-05-05 Thread Adrian Klaver
On 05/05/2018 10:41 AM, Alexander Farber wrote: Hi Adrian, There is a two-player word game: CREATE TABLE players (      uid SERIAL PRIMARY KEY,      name text NOT NULL ); CREATE TABLE games (      gid SERIAL PRIMARY KEY,   

Re: ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification

2018-05-05 Thread Alexander Farber
Hi Adrian, On Sat, May 5, 2018 at 7:03 PM, Adrian Klaver wrote: > On 05/05/2018 07:49 AM, Alexander Farber wrote: > >> http://sqlfiddle.com/#!17/7e929/13 >> >> There is a two-player word game: >> >> CREATE TABLE players ( >> uid SERIAL PRIMARY KEY, >> name text NOT NULL >> ); >> >> CR

Re: ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification

2018-05-05 Thread Adrian Klaver
On 05/05/2018 07:49 AM, Alexander Farber wrote: Hello, I am struggling with an UPSERT in PostgreSQL 10.3 and have prepared a simple test case showing my 2 problems (at http://sqlfiddle.com/#!17/7e929/13 and also below) - There is a two-player word game: CREATE TABLE players (     uid SERIA

Re: ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification

2018-05-05 Thread Alexander Farber
Even the simpler INSERT statement INSERT INTO stats(uid, single_q_left) SELECT player1, COUNT(*) FROM games WHERE hand1 = '{Q}' GROUP BY player1 ON CONFLICT(uid) DO NOTHING; produces the same error. On Sat, May 5, 2018 at 4:49 PM, Alexander Farber wrote: > http://sqlfiddle.com/#!17/7e929/13 >

ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification

2018-05-05 Thread Alexander Farber
Hello, I am struggling with an UPSERT in PostgreSQL 10.3 and have prepared a simple test case showing my 2 problems (at http://sqlfiddle.com/#!17/7e929/13 and also below) - There is a two-player word game: CREATE TABLE players ( uid SERIAL PRIMARY KEY, name text NOT NULL ); CREATE TABLE