When indexing, the database calculates that the length of the key is incremented by the char length of all the fields that are used by index and then multiplied by the following scale to not exceed the specified key length of 1000:
Latin1 = 1 byte = 1 character
Uft8 = 3 byte = 1 character
GBK = 2 byte = 1 character
For example, to see more clearly, take GBK as an example:
CREATE UNIQUE INDEX ' Unique_record ' on reports (' Report_name ', ' report_client ', ' report_city ');
of which report_name varchar (report_client), report_city varchar (200)
(+ +200) * 2 = > 1000, all will be reported 1071 error, as long as the report_city changed to varchar (100) Then the index can be successfully established.
If the table is a UTF8 character set, the index is still not built.
MySQL error "Specified key was too long; Max key length is bytes "