How do I do the same for multiple conflicts in PostgreSQL?

For example, if I have a table:

create table test(

    username                varchar(50)   PRIMARY KEY,      
    customer                varchar(12),
    nickname                varchar(12)  
);

create unique index unique_customer_nickname on test(customer,nickname);

      

Therefore, the username is unique and (client, alias) together are unique.

Then if I want to write an upsert statement like this:

Insert into test(username,customer,nickname) values('utest','ctest','ntest') 
on conflict(username) or on conflict(customer,nickname) DO UPDATE ....

      

but that gives me a syntax error. I also tried on (conflict(username) or conflict(customer,nickname))

but this also returns a syntax error.

so I want different conflicts to do the same thing.

+3
sql postgresql


source to share


No one has answered this question yet

See similar questions:

60
Use multiple conflict_targets in the ON CONFLICT section

or similar:

3491
How can I UPDATE from SELECT in SQL Server?
2776
How can I prevent SQL injection in PHP?
1719
How to exit the PostgreSQL command line utility: psql
1591
PostgreSQL "DESCRIBE TABLE"
1522
Show tables in PostgreSQL
922
How to run PostgreSQL server on Mac OS X?
922
Which PostgreSQL version am I running?
904
How can I drop all tables in PostgreSQL database?
408
SQLite - UPSERT * not * INSERT OR REPLACE
208
How to UPSERT (MERGE, INSERT ... ON DUPLICATE UPDATE) in PostgreSQL?



All Articles
Loading...
X
Show
Funny
Dev
Pics