Understanding MySQL Text Field Limits

Asked 2 years ago, Updated 2 years ago, 40 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?

mysql

2022-09-30 13:56

1 Answers

The manual says:
https://dev.mysql.com/doc/refman/5.6/ja/string-type-overview.html

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


© 2024 OneMinuteCode. All rights reserved.