How to Resolve Returned String That was Truncated by MySQL

  • by
I think you might have used a group function called group_concat() in your SQL statement as I did and saw only 1024 characters returned in the result. And yes, there's a length limit 1024 by default imposed on this function.

Let's see what the document say about this:
The result is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024. The value can be set higher, although the effective maximum length of the return value is constrained by the value of max_allowed_packet. The syntax to change the value of group_concat_max_len at runtime is as follows, where val is an unsigned integer:

    SET [GLOBAL | SESSION] group_concat_max_len = val;
That is to say you'd better set group_concat_max_len to a higher value within either GLOBAL or SESSION scope. For example:
SQL> set session group_concat_max_len = 2048;
For more about the usage of said group function, you may refer to:
MySQL :: MySQL 5.7 Reference Manual :: 12.20.1 GROUP BY (Aggregate) Functions 

Leave a Reply

Your email address will not be published. Required fields are marked *