What is wrong with my SQL here? #1089 – Incorrect prefix key

In your PRIMARY KEY definition you’ve used (id(11)), which defines a prefix key – i.e. the first 11 characters only should be used to create an index. Prefix keys are only valid for CHAR, VARCHAR, BINARY and VARBINARY types and your id field is an int, hence the error.

Use PRIMARY KEY (id) instead and you should be fine.

MySQL reference here and read from paragraph 4.

Leave a Comment