Hello! H2 doesn't return names of constrains in these exceptions (maybe it will in future versions). If you need to find name of constraint, you need to check INFORMATION_SCHEMA.TABLE_CONSTRAINTS table. You need only rows where TABLE_SCHEMA and TABLE_NAME match schema and name of updated table.
* For primary key violations situation is simple, because a table may have only one such constraint, so you need a row with CONSTRAINT_TYPE = 'PRIMARY KEY'. * For unique index violations you need to read index name from exception and find a row with matched names in INDEX_SCHEMA and INDEX_NAME columns. *If there is no such row, it isn't a violation of a unique constraint, but it is a violation of unique index (and you already know name of this index), unique indexes may exist without constraints*. Alternatively you can parse column names from exception and search them in INFORMATION_SCHEMA.KEY_COLUMN_USAGE, but such check will be significantly more complicated than check by index name. Names of both primary key and unique constraints can be read from CONSTRAINT_SCHEMA and CONSTRAINT_NAME columns in matched rows. Indexes used by constraint may have any names, there is no mandatory suffix. Constraints can and will use any compatible existing index instead of own one if such index already exist, so you cannot determine name of constraint from name of its index without INFORMATION_SCHEMA.TABLE_CONSTRAINTS table. There is also a special case for names in exceptions. It is possible to create an index with non-ASCII or non-printable characters. Index PUBLIC.Ä (or PUBLIC.U&"\00c4", both names are equivalent in SQL) will be reported as "PUBLIC.U&""\\00c4"" in exception, but you need to find a row with INDEX_NAME = 'Ä' (or INDEX_NAME = U&'\00c4'). -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to h2-database+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/h2-database/c3d147b9-0339-4fd7-8113-f115068b144bn%40googlegroups.com.