Answers for "Postgres ignore duplicate and delete"

SQL
6

query postgres delete duplicates

DELETE FROM dups a USING (
      SELECT MIN(ctid) as ctid, key
        FROM dups 
        GROUP BY key HAVING COUNT(*) > 1
      ) b
      WHERE a.key = b.key 
      AND a.ctid <> b.ctid
Posted by: Guest on February-20-2020
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 "Postgres ignore duplicate and delete"

Code answers related to "SQL"

Browse Popular Code Answers by Language