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; 

 

相关内容

热门资讯

于此同时!wepoker免费脚... 您好,wepoker免费脚本弱密码这款游戏可以开挂的,确实是有挂的,需要了解加去威信【4852750...
来临!微信微乐小程序辅助软件,... 来临!微信微乐小程序辅助软件,微乐小程序黑科技,学习教程(有挂软件)-哔哩哔哩1、微信微乐小程序辅助...
透视辅助!aapoker透视脚... 透视辅助!aapoker透视脚本下载(透视)hhpoker有没有透视辅助-确实真的有挂(哔哩哔哩)1...
辅助透视!苹果手机微信小程序游... 辅助透视!苹果手机微信小程序游戏破解器,微乐小程序黑科技,课程教程(有挂工具)-哔哩哔哩1、操作简单...
昨日!wepoker轻量版透视... 昨日!wepoker轻量版透视方法(透视)wepoker俱乐部辅助-一贯是有挂(哔哩哔哩)小薇(辅助...
据统计!微乐自建房辅助入口官网... 据统计!微乐自建房辅助入口官网,微乐小程序免费黑科技,指引教程(有挂app)-哔哩哔哩运微乐自建房辅...
随着!德普之星的辅助工具介绍(... 随着!德普之星的辅助工具介绍(透视)德普之星辅助工具如何打开-总是是有挂(哔哩哔哩)亲,关键说明,德...
近期!微乐小程序辅助器出租,微... 近期!微乐小程序辅助器出租,微乐小程序免费黑科技,资料教程(有挂下载)-哔哩哔哩微乐小程序辅助器出租...
反观!智星德州插件怎么下载(透... 反观!智星德州插件怎么下载(透视)智星德州插件怎么下载-真是真的有挂(哔哩哔哩)一、智星德州插件怎么...
透视透视!微信微乐辅助ios,... 透视透视!微信微乐辅助ios,微乐小程序免费黑科技,办法教程(有挂下载)-哔哩哔哩1、实时微乐小程序...