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; 

 

相关内容

热门资讯

透视ai代打!wepoker挂... 透视ai代打!wepoker挂(透视)一贯真的是有辅助app(揭秘有挂)-哔哩哔哩1、每一步都需要思...
推荐透视!淘宝买wepoker... 推荐透视!淘宝买wepoker透视有用吗!技巧知识分享辅助挂(有挂解惑)-哔哩哔哩淘宝买wepoke...
透视有挂!wepoker辅助器... 透视有挂!wepoker辅助器有哪些功能(透视)一贯真的有辅助插件(有挂讲解)-哔哩哔哩1、wepo...
解谜透视!pokerrrr2辅... 解谜透视!pokerrrr2辅助!一分钟了解辅助软件(存在有挂)-哔哩哔哩1、pokerrrr2辅助...
出乎意料的是!德州透视hhpo... 出乎意料的是!德州透视hhpoker(透视)一贯是真的辅助工具(有挂详情)-哔哩哔哩1、打开软件启动...
专业透视!wepoker透视是... 专业透视!wepoker透视是真的吗!推荐一款辅助教程(有挂教程)-哔哩哔哩1、下载好wepoker...
更值得关注的是!aapoker... 更值得关注的是!aapoker怎么拿好牌(透视)总是是有辅助安装(有挂教程)-哔哩哔哩1)aapok...
科普透视!wepoker透视有... 科普透视!wepoker透视有吗!分享一款辅助技巧(有挂教程)-哔哩哔哩1、任何wepoker透视有...
透视透视!哈糖大菠萝万能挂(透... 透视透视!哈糖大菠萝万能挂(透视)确实存在有辅助app(果真有挂)-哔哩哔哩进入游戏-大厅左侧-新手...
科普透视!大菠萝免费辅助器!交... 科普透视!大菠萝免费辅助器!交流学习经验辅助神器(有挂秘籍)-哔哩哔哩在进入大菠萝免费辅助器软件靠谱...