In a CREATE TABLE statment, why "KEY" is used in this way? KEY `IDX_ATTRIBUTE_LABEL_ATTRIBUTE` (`attribute_id`)
I'm trying to understand this table structure. I never seen this kind of statement, is this some kind of foreign key?
there's n开发者_运维问答o table like *IDX_ATTRIBUTE_LABEL_ATTRIBUTE*
CREATE TABLE IF NOT EXISTS `eav_attribute_label (
`attribute_label_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`attribute_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`store_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`value` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`attribute_label_id`),
KEY `IDX_ATTRIBUTE_LABEL_ATTRIBUTE` (`attribute_id`),
KEY `IDX_ATTRIBUTE_LABEL_STORE` (`store_id`),
KEY `IDX_ATTRIBUTE_LABEL_ATTRIBUTE_STORE` (`attribute_id`,`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
thanks
In this case KEY is a synonym for INDEX, it is not a foreign key.
Note - index on attribute_id
is redundant because there is composite index (attribute_id
,store_id
).
精彩评论