Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, there are 2 ways to accomplish this:</p> <ol> <li>using _bin collation</li> <li>change your datatype to VARBINARY</li> </ol> <p><strong>Case 1: using _bin collation</strong></p> <p>Create your table as follows:</p> <pre><code>CREATE TABLE `dictionary` ( `a` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, UNIQUE KEY `idx_un_a` (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; </code></pre> <p>Please note:</p> <ol> <li>the datatype of the column <code>a</code></li> <li>the UNIQUE index on column <code>a</code></li> </ol> <p><strong>Case 2: using VARBINARY dataype</strong></p> <p>Create your table as follows:</p> <pre><code>CREATE TABLE `dictionary` ( `a` VARBINARY(128) NOT NULL, UNIQUE KEY `idx_uniq_a` (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; </code></pre> <p>Please note:</p> <ol> <li>the new datatype VARBINARY</li> <li>the UNIQUE index on column <code>a</code></li> </ol> <p>So, both the above will solve your purpose. That is, they both will allow values like 'abc', 'Abc', 'ABC', 'aBc' etc but not allow the same value again if the case matches.</p> <p>Please note that giving an "_bin" collation is different than using the binary datatype. So please feel free to refer to the following links:</p> <ol> <li><a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html" rel="nofollow">The BINARY and VARBINARY datatypes</a></li> <li><a href="http://dev.mysql.com/doc/refman/5.0/en/charset-binary-collations.html" rel="nofollow">The _bin and binary Collations</a></li> </ol> <p>I hope the above helps!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload