0

db version: 10.1.35-MariaDB

charset: utf8

I was getting error: Specified key was too long; max key length is 767 bytes so I changed column length to 255. But i need to allow varchar(1000) in column, so when I enter large data in db column it says: Warning: #1265 Data truncated for column

How can I allow large data?

Irfan Y
  • 1,242
  • 2
  • 21
  • 68
  • 1
    'But i need to allow varchar(1000) in column,' - then it cannot be a key and you should read this https://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes – P.Salmon Jul 11 '19 at 07:19
  • See my list of [_5 workarounds for 767_](http://mysql.rjweb.org/doc.php/limits#767_limit_in_innodb_indexes) -- each has a caveat, so you have to decide which you can live with. – Rick James Jul 12 '19 at 04:01

2 Answers2

0

Try making the column length max, then it will work

ALTER TABLE table_name
MODIFY COLUMN column_name datatype(MAX);
Nicola Ambrosetti
  • 2,567
  • 3
  • 22
  • 38
0

Thanks to @P.Salmon.

The column length restriction is only for keys. All other columns can have any length.

Irfan Y
  • 1,242
  • 2
  • 21
  • 68