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; 

 

相关内容

热门资讯

辅助透视!wpk有作弊吗,四川... 辅助透视!wpk有作弊吗,四川熊猫辅助软件(本来是真的有挂);1、每一步都需要思考,不同水平的挑战会...
透视有挂!wepoker辅助工... 1、透视有挂!wepoker辅助工具,如何下载wpk透视版(详细辅助扑克教程);详细教程。2、如何下...
wepoker透视脚本免费!w... 您好,wepoker透视脚本免费这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】...
透视科技“hhpoker透视功... 透视科技“hhpoker透视功能如何下载”好像是有挂(辅助挂)详细辅助2025新版总结是一种具有地方...
透视ai!智星德州辅助译码插件... 透视ai!智星德州辅助译码插件靠谱吗,佛手在线辅助,解密教程(有挂详情)1)佛手在线辅助辅助挂:进一...
透视有挂!wpk模拟器多开,新... 透视有挂!wpk模拟器多开,新九五辅助微信脚本(本来有挂);1、下载好新九五辅助微信脚本辅助软件之后...
wepoker透视脚本网页!w... wepoker透视脚本网页!wpk辅助器,wepoker辅助工具(详细辅助AI教程)1、在wepok...
透视软件!wepoker辅助器... 透视软件!wepoker辅助器是真的的吗,xpoker怎么作弊(详细辅助黑科技教程)1、许多玩家不知...
透视挂“wepoker透视脚本... 透视挂“wepoker透视脚本网页”都是有挂(辅助挂)详细辅助2025新版教程1、系统规律教程、辅助...
透视总结!德普之星app安卓版... 透视总结!德普之星app安卓版破解版,财神13张辅助器下载,攻略教程(有挂辅助)1、玩家可以在财神1...