Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

meaning of a KEY in CREATE TABLE statment in mysql

Tags:

sql

mysql

I am working with mysql .

I have checked the CREATE table statement , and I saw there a KEY word

| pickupspc | CREATE TABLE `pickupspc` (
  `McId` int(11) NOT NULL,
  `Slot` int(11) NOT NULL,
  `FromTime` datetime NOT NULL,
  `ToTime` datetime NOT NULL,
  `Head` int(11) NOT NULL,
  `Nozzle` int(11) DEFAULT NULL,
  `FeederID` int(11) DEFAULT NULL,
  `CompName` varchar(64) DEFAULT NULL,
  `CompID` varchar(32) DEFAULT NULL,
  `PickUps` int(11) DEFAULT NULL,
  `Errors` int(11) DEFAULT NULL,
  `ErrorCode` varchar(32) DEFAULT NULL,
  KEY `ndx_PickupSPC` (`McId`,`Slot`,`FromTime`,`ToTime`,`Head`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |

But what is the meaning of it ? It's not like a PRIMARY KEY right ?

Thanks .

like image 463
Night Walker Avatar asked Jul 12 '11 08:07

Night Walker


1 Answers

It is simply a synonym for INDEX. It creates an index with the name ndx_PickupSPC on the columns specified in parenthesis.

See the CREATE TABLE syntax for more information.

like image 170
Mike Avatar answered Oct 13 '22 19:10

Mike