In any case, there are three possible values for the “Key” attribute:
- PRI
- UNI
- MUL
The meaning of PRI and UNI are quite clear:
- PRI=> primary key
- UNI=> unique key
The third possibility, MUL, (which you asked about) is basically an index that is neither a primary key nor a unique key. The name comes from “multiple” because multiple occurences of the same value are allowed. Straight from the MySQL documentation:
“If Key
is MUL
, the column is the first column of a nonunique index in which multiple occurrences of a given value are permitted within the column.”
There is also a final caveat:
“If more than one of the Key values applies to a given column of a table, Key displays the one with the highest priority, in the order PRI
, UNI
, MUL
.”
As a general note, the MySQL documentation is quite good. When in doubt, check it out!
Hmm… your post strangely resembles this answer in Stack Overflow (posted 2 months before your post): http://stackoverflow.com/a/15268888/339176
Can you explain this?
LikeLiked by 6 people
Not helpful.
LikeLiked by 1 person
MUL is a Foreign Key of some Primary key
its My Table
CREATE TABLE `employees` (
`employeeNumber` int(11) NOT NULL,
`lastName` varchar(50) NOT NULL,
`firstName` varchar(50) NOT NULL,
`extension` varchar(10) NOT NULL,
`email` varchar(100) NOT NULL,
`officeCode` varchar(10) NOT NULL,
`reportsTo` int(11) DEFAULT NULL,
PRIMARY KEY (`employeeNumber`),
KEY `reportsTo` (`reportsTo`),
KEY `officeCode` (`officeCode`),
CONSTRAINT `employees_ibfk_1` FOREIGN KEY (`reportsTo`) REFERENCES `employees` (`employeeNumber`),
CONSTRAINT `employees_ibfk_2` FOREIGN KEY (`officeCode`) REFERENCES `offices` (`officeCode`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
And its a Desc
“Field”: “officeCode”,
“Type”: “varchar(10)”,
“Null”: “NO”,
“Key”: “MUL”,
“Default”: null,
“Extra”: “”
MUL Allows you to Enter multiple same Value Which is present in Primary Key
LikeLike
ganesh kando big like my man!!!!!
LikeLiked by 1 person