Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

What should I do if #1071 - specified key was too long; max key length is 767 bytes?

Asked by Gareth Beacham Oct 3, 2022 1.3K views 1 answer
Share

About this question

Our server is creating a lot of tables and one of them is the Lock_ table.

We are using MySQL 5.5 on Percona. Also we are using utf8_general_ci and utf8.

It throws the following error when creating the following index on Lock_ table:

ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes

Here is the create-table query:

create table Lock_ (
    uuid_ VARCHAR(75) null,
    lockId LONG not null primary key,
    companyId LONG,
    userId LONG,
    userName VARCHAR(75) null,
    createDate DATE null,
    className VARCHAR(75) null,
    key_ VARCHAR(200) null,
    owner VARCHAR(255) null,
    inheritable BOOLEAN,
    expirationDate DATE null
);

Index query:

create unique index IX_DD635956 on Lock_ (className, key_, owner);

This problem is happening on one of our prod servers (previously it was standalone mysql and then later moved to percona, but the problem was present in both the editions), but this is working fine on our dev environment.

So is there a way we can update the prod environment's index length or something so that it does not throw this error?

Your answer

1 Answer

More SQL Server discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest SQL Server Blogs

Guides, tips and career advice on SQL Server from JanBask experts.