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透视辅助方法,有哪些免费的wpk作必弊码(透视)真是是真的app(哔哩哔哩);1、上...
脚本解谜!hhpoker软件安... 脚本解谜!hhpoker软件安装包,hhpoker视频巡查真的假的(透视)一直真的是有插件(哔哩哔哩...
脚本分享!wpk显示有作必弊,... 脚本分享!wpk显示有作必弊,wpk俱乐部辅助器(透视)总是真的有软件(哔哩哔哩)1、让任何用户在无...
透视关于!wepoker怎么拿... 透视关于!wepoker怎么拿到好牌,wepokerplus辅助(透视)确实真的是有app(哔哩哔哩...
透视详情!hhpoker怎么破... 透视详情!hhpoker怎么破解,hhpoker底牌透视脚本(透视)总是真的有技巧(哔哩哔哩)1、实...
脚本透视!aapoker脚本,... 脚本透视!aapoker脚本,aapoker如何设置胜率(透视)总是是有技巧(哔哩哔哩)小薇(辅助器...
脚本详情!德普之星辅助工具如何... 脚本详情!德普之星辅助工具如何设置,德普之星辅助工具如何打开(透视)总是真的是有脚本(哔哩哔哩)脚本...
透视推荐!wpk官网下载链接,... 透视推荐!wpk官网下载链接,wpk透视辅助(透视)都是是真的教程(哔哩哔哩)1、超多福利:超高返利...
脚本详情!wpk辅助器,wpk... 脚本详情!wpk辅助器,wpk德州局怎么透视(透视)好像是真的软件(哔哩哔哩)1、德州局怎么透视破解...
透视分享!wejoker透视方... 透视分享!wejoker透视方法,wepoker黑侠辅助器(透视)都是真的有脚本(哔哩哔哩)1、用户...