Skip to content
Advertisement

make text column as unique key

i want to make a table in MySQL server with mediumtext column as UNIQUE KEY

but this made an error

when I change the type of `name` to varchar .. it works!

can you tell if i can to make text column as UNIQUE KEY

Advertisement

Answer

Basically you can not use Text column as UNIQUE key. Because practically such a big column will not be unique and there might be a chance of more duplicates. So go for hashing method and use that output as a UNIQUE constraint.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement