Use multiple conflict_target in ON CONFLICT clause

前端 未结 9 793
傲寒
傲寒 2020-11-29 02:25

I have two columns in table col1, col2, they both are unique indexed (col1 is unique and so is col2).

I need at insert into this table, u

9条回答
  •  渐次进展
    2020-11-29 02:35

    If you are using postgres 9.5, you can use the EXCLUDED space.

    Example taken from What's new in PostgreSQL 9.5:

    INSERT INTO user_logins (username, logins)
    VALUES ('Naomi',1),('James',1)
    ON CONFLICT (username)
    DO UPDATE SET logins = user_logins.logins + EXCLUDED.logins;
    

提交回复
热议问题