开发者

MySQL keys: PRIMARY KEY, FOREIGN KEY, KEY -- what is "KEY"?

Looking at a "mysqldump -d" and see a key that is KEY, not "PRIMARY KEY" or "FOREIGN KEY"

What is KEY?

Example:

CREATE TABLE IF NOT EXISTS `TABLE_001` (
  `COL_001` int(256) NOT NULL,
  `COL_002` int(256) NOT NULL,
  `COL_003` int(256) NOT NULL,
  `COL_004` int(256) NOT NULL,
  `COL_005` int(256) NOT NULL,
  `COL_006` int(256) NOT NULL,
  `COL_007` int(256) NOT NULL,
  `COL_008` int(256) NOT NULL,
  `COL_009` int(256) NOT NULL,
  `COL_010` int(256) NOT NULL,
  `COL_011` int(256) NOT NULL,
  `COL_012` int(256) NOT NULL,
  PRIMARY KEY  (`COL_001`),
  KEY `COL_002` (`COL_002`,`COL_003`),
 开发者_运维百科 KEY `COL_012` (`COL_012`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Also, when I'm create a new version of this table, will changing MyISAM to InnoDB require any additional changes besides "ENGINE=MyISAM" to "ENGINE=InnoDB"?


KEY is alternative syntax for index declaration. The CREATE TABLE statement includes creating two indexes, on COL_002 and COL_012 separately.

...when I'm create a new version of this table, will changing MyISAM to InnoDB require any additional changes besides "ENGINE=MyISAM" to "ENGINE=InnoDB"?

No, that should be fine but be aware that you can't use MySQL's native Full Text Search (FTS) on tables using the Innodb engine -- they have to be MyISAM before you can full text index columns in them.


From MySQL manual for CREATE TABLE syntax:

KEY is normally a synonym for INDEX.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜