62

Are indices (indexes) defined as UNIQUE case sensitive in MySQL?

1
  • As per popular demand, maybe you should update the chosen answer. Commented Jan 19, 2013 at 14:00

2 Answers 2

100

It depends on the collation of the field - if it's ci (case insensitive) or cs (case sensitive). The unique index would apply accordingly.

Sign up to request clarification or add additional context in comments.

Comments

27

You can make a column case-sensitive by using this syntaxis. the unique index also will be case-sensitive.

ALTER TABLE tbl_name MODIFY
col_name column_definition
[CHARACTER SET charset_name]
[COLLATE collation_name]

Example:

ALTER TABLE `tablename` MODIFY
`column` VARCHAR(100) 
CHARACTER SET utf8
COLLATE utf8_bin;

Note: utf8_bin compares strings by the binary value of each character in the string.

Tested on Msql 5.5.X

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.