title: Is it possible to set constraints for a VARCHAR column in MySQL?
body: <p>Is it possible to set constraints for VARCHAR columns in MySQL?</p>
  
  <p>I would like to not permit more than one row of a specific value. </p>
  
  <pre><code>   ______________
    |    MyTable   |
     --------------
    | pk id   INT  |
    | name VARCHAR |
  </code></pre>
  
  <p>If I now inserted two rows with the same name, "peter", I would like to throw an error. So, the constraint should only check if there is already a "peter" stored. But multiple rows of other values have to work.</p>
  
  <pre><code>INSERT INTO MyTable VALUES (1, "peter");
  INSERT INTO MyTable VALUES (2, "peter"); // This should fail
  INSERT INTO MyTable VALUES (3, "steven"); 
  INSERT INTO MyTable VALUES (4, "steven"); // Shall succeed
  </code></pre>
  
  <p>Is it possible in some way in MySQL to check for specified values?</p>