Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: [OT] SQL "on duplicate key" custom actionby erix (Prior) |
on Oct 21, 2019 at 09:43 UTC ( [id://11107753]=note: print w/replies, xml ) | Need Help?? |
if the primary key exists, it should silently ignore the record if all the other columns match, but throw an error if they don't. I'd think a unique index including any extra columns would make this version of your INSERT work:
which yields:
Postgres 12.1 (but this works from 9.5.x onward) Manual PostgreSQL 12.1: INSERT # SQL-ON-CONFLICT update: The first INSERT should be the same, of course, fixed. Also, removed vestiges of the original bash-version. update 2: Re 'MySQL vs. Postgres': I think open-sourced and completely-free PostgreSQL is a better/safer choice than proprietary Oracle MySQL. For one thing, over time Pg will get better -- even better than Oracle -- but how could Oracle ever allow cheapo MySQL to overtake its venerable and expensive Oracle database product?
In Section
Seekers of Perl Wisdom
|
|