Understanding MySQL Text Field Limits

Asked 2 months ago, Updated 2 months ago, 2 views

Mysql2::Error:Data too long for column 'hoge' at row1

I'm in trouble because I got this kind of error.
hoge is text type, so I thought there was no limit...

By the way, the data that failed this time was about 67441 characters including full-width half-width characters.

What type of data should I use if I can't handle text?


2022-09-30 13:56

1 Answers

The manual says:

TEXT column with a maximum length of 65,535 (216-1) characters.If the value contains multi-byte characters, the maximum valid length is less.

It's a complicated way to write, but the bottom line is 65,535 bytes.

If TEXT is not enough, you can use MEDIUMTEXT (16,777,215 bytes) and LONGTEXT (4,294,967,295 bytes).

There is no data type without a limit.

2022-09-30 13:56

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.