Using MySQL, when I have a table with (for example) three keys (one primary, auto-increment, and two uniques on a column, eg. 'code' and 'name'), how can I (efficiently) know which uniqueness constraint was violated when doing an insert?
You get an error #1062 - Duplicate entry 'Value' for key 2
, but how do I know key 2 is the key for the 'code' column and not the 'name' column?
We develop this application with multiple developers, and I want to prevent the day we don't add the constraints to a table in the same order, so the second key on my machine is the third key on another machine, and vice-versa.
Mapping to the exact column names involved is not really necessary, just to the key names is enough.