MySQL error: key specification without a key length

前端 未结 16 1104
别跟我提以往
别跟我提以往 2020-11-22 08:41

I have a table with a primary key that is a varchar(255). Some cases have arisen where 255 characters isn\'t enough. I tried changing the field to a text, but I get the foll

相关标签:
16条回答
  • 2020-11-22 09:19

    I know it's quite late, but removing the Unique Key Constraint solved the problem. I didn't use the TEXT or LONGTEXT column as PK , but I was trying to make it unique. I got the 1170 error, but when I removed UK, the error was removed too.

    I don't fully understand why.

    0 讨论(0)
  • 2020-11-22 09:20

    You can specify the key length in the alter table request, something like:

    alter table authors ADD UNIQUE(name_first(20), name_second(20));
    
    0 讨论(0)
  • 2020-11-22 09:20

    Go to mysql edit table-> change column type to varchar(45).

    0 讨论(0)
  • 2020-11-22 09:20

    Use like this

    @Id
    @Column(name = "userEmailId", length=100)
    private String userEmailId;
    
    0 讨论(0)
提交回复
热议问题