group_concat_max_len¶
group_concat_max_len bounds the maximum length of a GROUP_CONCAT result in bytes; results longer than the limit are truncated, and the default is the MySQL-compatible value of 1024.
Description¶
group_concat_max_len is a system variable that limits the maximum length of the string produced by the GROUP_CONCAT() aggregate function. When a GROUP_CONCAT() result would be longer than this value, MatrixOne truncates the result to fit.
The variable is MySQL-compatible and defaults to 1024 bytes. The minimum allowed value is 4. It can be set at both the global and session scope and is effective immediately for subsequent queries in the session.
Syntax¶
SET group_concat_max_len = number_of_bytes
Arguments¶
group_concat_max_len takes a single value: an integer number of bytes. The minimum allowed value is 4 and the default is 1024.
Examples¶
DROP DATABASE IF EXISTS group_concat_max_len_demo;
CREATE DATABASE group_concat_max_len_demo;
USE group_concat_max_len_demo;
CREATE TABLE t (id INT, s VARCHAR(16));
INSERT INTO t VALUES (1, 'aa'), (2, 'bb'), (3, 'cc');
SET group_concat_max_len = 1024;
SELECT group_concat(s ORDER BY s SEPARATOR '') AS full_result FROM t;
SET group_concat_max_len = 5;
SELECT group_concat(s ORDER BY s SEPARATOR '') AS truncated_result FROM t;
SET group_concat_max_len = 1024;
DROP DATABASE group_concat_max_len_demo;