Keyname | Type | Unique | Packed | Column | Cardinality | Collation | Null | Comment |
---|---|---|---|---|---|---|---|---|
PRIMARY | BTREE | Yes | No | ID | 7 | A | No | |
AD_ID | BTREE | Yes | No | AD_ID USER_ID |
1 2 |
A A |
No Yes |
|
USER_ID | BTREE | No | No | USER_ID | 2 | A | Yes |
How can the column of USER_ID
be unique and at the same time not be unique as you can see in the indexes table?
2
Answers
The answer is yes, it happens, it’s called a database inconsistency problem or corruption. But in this case I see the user_id and AD_ID is a bit weird but that’s by design.
Column
USER_ID
alone is not unique, but the combination ofAD_ID
andUSER_ID
is.Example: