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; 

 

相关内容

热门资讯

透视好友房!hhpoker外挂... 透视好友房!hhpoker外挂靠谱吗,新鸿狐软件下载,规律教程(有挂详情)1、打开软件启动之后找到中...
透视安装!hhpoker怎么开... 透视安装!hhpoker怎么开透视(透视)爆料教程(其实真的是有挂)透视安装!hhpoker怎么开透...
透视攻略!wepoker辅助透... 透视攻略!wepoker辅助透视软件(透视)外挂透明挂辅助工具(竟然有挂);实战中需综合运用上述技巧...
透视插件!aa poker辅助... 透视插件!aa poker辅助包,有没有人会衢州都莱的辅助,2025新版技巧(有挂教程);该软件可以...
透视教学!wepoker底牌透... 透视教学!wepoker底牌透视脚本http(透视)安装教程(确实是有挂);1、wepoker底牌透...
透视了解!智星德州菠萝安装(透... 透视了解!智星德州菠萝安装(透视)外挂透明挂辅助挂(从前真的是有挂);支持多人共享记分板与复盘,通过...
透视数据!hhpoker透视脚... 透视数据!hhpoker透视脚本下载,小闲川南辅助,黑科技教程(有挂揭秘)1、超多福利:超高返利,海...
透视好牌!德普之星透视辅助插件... 透视好牌!德普之星透视辅助插件(透视)教你攻略(一直是真的有挂);1、操作简单,无需注册,只需要使用...
透视中牌率!hhpoker辅助... 透视中牌率!hhpoker辅助下载(透视)外挂透明挂辅助安装(原本存在有挂);支持2-10人实时对战...
透视免费!wepoker透视脚... 透视免费!wepoker透视脚本下载,微信小程序财神十三脚本app,微扑克教程(有挂详情);1、微信...