MySQL Forums
Forum List  »  Newbie

Re: Duplicate Entry on varchar field PK?
Posted by: Russell Dyer
Date: July 06, 2005 06:34PM

Using Felix's idea of making the collation of the column binary, if you want to alter an existing table and column, you could do the following:

ALTER TABLE TMP_TEST
DROP PRIMARY KEY,
CHANGE COLUMN col1 col1 VARCHAR(10) COLLATE latin1_bin PRIMARY KEY;

This is assuming that your default column character set and collation would be latin1. Otherwise you use the appropriate one for you language. To get a list of collation sets available, enter this statement:

SHOW COLLATION LIKE '%bin%';

Russell Dyer

Author of "MySQL in a Nutshell" (O'Reilly 2005).

Options: ReplyQuote


Subject
Written By
Posted
Re: Duplicate Entry on varchar field PK?
July 06, 2005 06:34PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.