Reputation: 61
I have this table
CREATE TABLE my_table
(
my_column varchar(10) UNIQUE
);
I want to insert duplicate values. PostgreSQL throws an ERROR about the UNIQUE column.
How to ignore the duplicate rows being inserted?
For example:
INSERT INTO my_table (my_column)
VALUES ('cat'), ('dog'), ('cat') ;
I want to have table with this data after this statement:
cat
dog
Upvotes: 0
Views: 56
Reputation:
Use on conflict
INSERT INTO my_table (my_column)
VALUES
('cat'), ('dog'),('cat')
on conflict do nothing;
Upvotes: 3