MySQL Forums
Forum List  »  Newbie

Re: how to prevent duplicate rows but allow duplicate column entries
Posted by: laptop alias
Date: October 04, 2008 06:18AM

The key can actually be 1000 bytes.

So maybe you could use a separate field for your PRIMARY KEY, and then guarantee uniqueness on only the first 333 bytes of each field like so:

DROP TABLE IF EXISTS `names`;

CREATE TABLE IF NOT EXISTS `names` (
`id` int(11) NOT NULL auto_increment,
`fname` text NOT NULL,
`mname` text NOT NULL,
`lname` text NOT NULL,
`rank` int(11) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`fname`(333),`mname`(333),`lname`(333))
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;

Options: ReplyQuote




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.