meaning of a KEY in CREATE TABLE statment in mysql

Viewed 10650

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 .

4 Answers

Key and index are the same. The word Key in the table creation is used to create an index, which enables faster performance.

In the above code, Key ndx_PickupSPC means that it is creating an index by the name ndx_PickupSPC on the columns mentioned in parenthesis.

Related