0

I need to define a column with the maximum possible length of VARCHAR. This field is primary key. I could not use LONGTEXT. I tried to define it with VARCHAR (65,535) but this generates error:

ERROR 1071: Specified key was too long; max key length is 3072 bytes
SQL Statement:

When I define: VARCHAR (3072), the ame error still appear. What is the maximus size I can use for VARCHAR?

Shadow
  • 33,525
  • 10
  • 51
  • 64
user9371654
  • 2,160
  • 16
  • 45
  • 78
  • the answer is no, you can't. For the varchar Question try https://stackoverflow.com/questions/13506832/what-is-the-mysql-varchar-max-size – snitch182 Oct 04 '18 at 11:15
  • please try not to put two questions in one ! It is a basic rule on this site. – snitch182 Oct 04 '18 at 11:16
  • Question is unclear i advice you to read https://stackoverflow.com/help/how-to-ask section "Help others reproduce the problem" – Raymond Nijland Oct 04 '18 at 11:16
  • answer to index lenght see: https://dev.mysql.com/doc/refman/8.0/en/innodb-restrictions.html "The index key prefix length limit is 3072 bytes for InnoDB tables that use DYNAMIC or COMPRESSED row format." – snitch182 Oct 04 '18 at 11:18
  • The size in byte is not the same as size in terms of number of characters. Most character sets require multiple bytes per character. Also bear in mind that the max length of a field is not necessarily the same as the max length of an index. – Shadow Oct 04 '18 at 12:02

0 Answers0