In MySQL 5.7
-
alter table mydb.roles add constraint uk1 unique (role_name);
-
alter table mydb.roles add constraint uk2 unique (role_name);
The 2nd alter
command threw me a warning stating:
Duplicate index 'uk2' defined on the table 'world_x.roles'. This is
deprecated and will be disallowed in a future release.
When I tried the same in Postgres(10.x), it didn't warn me.
So, what would the SQL standard be in this scenario?
Best Answer
It can be result very confusing mixing names constraints and slow down your queries because they have the same name
maybe this results helpful
Example
No double constraint and no warning message and you keep the SQL rules alive
As you can see at the following link, in fact these scenario is a bug
https://bugs.mysql.com/bug.php?id=37520
and finally recognized in: https://bugs.mysql.com/bug.php?id=8565
and finally fixed in MySQL Server 5.6.7