Answers for "ON DUPLICATE KEY UPDATE for postgres"

SQL
0

ON DUPLICATE KEY UPDATE for postgres

INSERT INTO the_table (id, column_1, column_2) 
VALUES (1, 'A', 'X'), (2, 'B', 'Y'), (3, 'C', 'Z')
ON CONFLICT (id) DO UPDATE 
  SET column_1 = excluded.column_1, 
      column_2 = excluded.column_2;
Posted by: Guest on November-06-2021
0

To ignore duplicate keys during 'copy from' in postgresql

create temp table tmp_table on commit drop as select * from brand with no data;
copy tmp_table (name,slug) from '/var/lib/postgresql/data/Brands.csv' DELIMITER ',' csv header;
insert into brand select distinct on (slug) * from tmp_table;
Posted by: Guest on March-30-2021

Code answers related to "ON DUPLICATE KEY UPDATE for postgres"

Code answers related to "SQL"

Browse Popular Code Answers by Language