mysql-造数据/列转行
创始人
2024-12-28 13:35:34
0

-- MySQL 列转行

set global group_concat_max_len=102400; set group_concat_max_len=102400; SELECT @@global.group_concat_max_len; SELECT @@group_concat_max_len; select table_name,concat(group_concat(COLUMN_NAME order by ORDINAL_POSITION separator ',')) as all_columns from information_schema.COLUMNS tb1 where table_schema='test' and table_name='table1' group by table_name;

使用方法:

mysql> set group_concat_max_len=102400; Query OK, 0 rows affected (0.00 sec)  mysql> SELECT @@global.group_concat_max_len; +-------------------------------+ | @@global.group_concat_max_len | +-------------------------------+ |                        102400 | +-------------------------------+ 1 row in set (0.00 sec)  mysql> SELECT @@group_concat_max_len; +------------------------+ | @@group_concat_max_len | +------------------------+ |                 102400 | +------------------------+ 1 row in set (0.00 sec)  mysql> select table_name,concat(group_concat(COLUMN_NAME order by ORDINAL_POSITION separator ',')) as all_columns     -> from information_schema.COLUMNS tb1     -> where table_schema='ccic_prod_mass1'     -> and table_name='t_pa_mass_policy_index'     -> group by table_name; +------------------------+------------------------------------------------------------------------------------------------------------------------------+ | table_name             | all_columns                                                                                                                  | +------------------------+------------------------------------------------------------------------------------------------------------------------------+ | t_pa_mass_policy_index | INDEX_RECORD_ID,BUSINESS_OBJECT_ID,INDEX_ID,POLICY_ID,FIELD_VALUE,DYNAMIC_FIELDS,INSERT_TIME,UPDATE_TIME,INSERT_BY,UPDATE_BY | +------------------------+------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)  mysql>    ##把去除自增列把本表数据重复插入本表 insert into  ccic_prod_mass1.t_pa_mass_policy_index(BUSINESS_OBJECT_ID,INDEX_ID,POLICY_ID,FIELD_VALUE,DYNAMIC_FIELDS,INSERT_TIME,UPDATE_TIME,INSERT_BY,UPDATE_BY) select BUSINESS_OBJECT_ID,INDEX_ID,POLICY_ID,FIELD_VALUE,DYNAMIC_FIELDS,INSERT_TIME,UPDATE_TIME,INSERT_BY,UPDATE_BY from ccic_prod_mass2.t_pa_mass_policy_index; 

 

相关内容

热门资讯

实操分享!aapoker脚本怎... 实操分享!aapoker脚本怎么用(透视)辅助工具(切实真的是有挂)-哔哩哔哩1、起透看视 辅助软件...
日前!闲逸透视app使用教程!... 日前!闲逸透视app使用教程!本来有挂辅助下载(有挂方法)-哔哩哔哩闲逸透视app使用教程透视方法中...
透视ai!hhpoker软件安... 透视ai!hhpoker软件安装包(透视)辅助神器(有挂教学)-哔哩哔哩1、hhpoker软件安装包...
我来教教大家!aapoker ... 我来教教大家!aapoker ai插件,德州局透视脚本免费版下载手机版,专业教程(有挂详情)-哔哩哔...
截至发稿!福建天天开心王国辅助... 截至发稿!福建天天开心王国辅助!总是是有辅助挂(有挂总结)-哔哩哔哩1、上手简单,内置详细流程视频教...
有消息称!wepokerplu... 有消息称!wepokerplus开挂(透视)wepoker透视脚本免费-一贯是有辅助工具(哔哩哔哩)...
今年以来!hhpoker必备开... 今年以来!hhpoker必备开挂(透视)辅助app(真的有挂)-哔哩哔哩1、操作简单,无需hhpok...
一分钟教你!fishpoker... 一分钟教你!fishpoker透视底牌,哈糖大菠萝辅助器,辅助教程(有挂透视)-哔哩哔哩暗藏猫腻,小...
据悉!余干中至五十k有挂装不!... 据悉!余干中至五十k有挂装不!原来有挂辅助平台(存在有挂)-哔哩哔哩1、游戏颠覆性的策略玩法,独创攻...
必备辅助推荐!wepoker辅... 必备辅助推荐!wepoker辅助工具(透视)wepoker脚本下载-确实存在有辅助攻略(哔哩哔哩)1...