MySQL group_concat_max_len

MySQL提供的group_concat函数可以拼接某个字段值成字符串,如 select group_concat(user_name) from sys_user,默认的分隔符是 逗号,即"," ,如果需要自定义分隔符可以使用 SEPARATOR

如:select group_concat(user_name SEPARATOR '_')  from sys_user

但是如果 user_name  拼接的字符串的长度字节超过1024 则会被截断。

通过命令 "show variables like 'group_concat_max_len' " 来查看group_concat 默认的长度:

 

操作方法:

(1)在MySQL配置文件中加入:

group_concat_max_len = 102400

(2)更简单的操作方法,执行SQL语句:

SET GLOBAL group_concat_max_len = 102400;

SET SESSION group_concat_max_len = 102400;

注意:该方法缺点是重启服务后设置失效

posted @   silentmuh  阅读(7032)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
Live2D
欢迎阅读『MySQL group_concat_max_len』
  1. 1 Walk Thru Fire Vicetone
  2. 2 爱你 王心凌
  3. 3 Inspire Capo Productions - Serenity
  4. 4 Welcome Home Radical Face
  5. 5 粉红色的回忆 李玲玉
Inspire - Capo Productions - Serenity
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

纯音乐,请欣赏

点击右上角即可分享
微信分享提示