Menu

#2332 (ok 2.11) UNIQUE and INDEX keys should not both be set

2.8.1
fixed
Interface (555)
1
2014-08-16
2007-01-03
osde-info
No

UNIQUE and INDEX keys "CAN" both be set for a column

and you should NOT delete the additional keys (that phpmyadmin implies/suggests !)

similar to
[ 1083301 ]
More than one INDEX key was created for column

[ 1482401 ]
"PRIMARY and INDEX keys should not both be set for column"

CREATE TABLE `mytab` (
`c` tinyint(4) default NULL,
`d` tinyint(4) default NULL,
UNIQUE KEY `idxc` (`c`),
KEY `idxcd` (`c`,`d`)
) ENGINE=MyISAM

Discussion

  • Marc Delisle

    Marc Delisle - 2007-01-03

    Logged In: YES
    user_id=210714
    Originator: NO

    Ok because you have a key on a single column and the other one is a composite key. Do you agree that, if you had this:
    UNIQUE KEY `idxc` (`c`),
    KEY `idxcd` (`c`)

    then the warning should be displayed?

     
  • Sebastian Mendel

    Logged In: YES
    user_id=326580
    Originator: NO

    yes, as you already see in bug #1083301 and #1482401 this problem is already known - so this is a duplicate

    btw. of course you CAN set as much indexes as you want (and MySQL supports) on the same columns - but it makes no sense if they are equal and having PRIMARY and KEY an the same column is equal. - it just takes more time to update all those indexes.

     
  • Sebastian Mendel

    • assigned_to: nobody --> cybot_tm
    • status: open --> open-accepted
     
  • Sebastian Mendel

    • priority: 5 --> 1
    • summary: UNIQUE and INDEX keys should not both be set for column --> (ok 2.11) UNIQUE and INDEX keys should not both be set
    • status: open-accepted --> open-fixed
     
  • Sebastian Mendel

    Logged In: YES
    user_id=326580
    Originator: NO

    fixed in trunk, will be in 2.11

     
  • Marc Delisle

    Marc Delisle - 2007-08-21
    • status: open-fixed --> closed-fixed
     
  • Michal Čihař

    Michal Čihař - 2013-06-11
    • Status: closed-fixed --> fixed