041.mysql-查询mysql元数据来格式化datax同步脚本,查询语句、拼接的json语句datax-mysql到hive
--自动生成json数据 select TABLE_NAME , concat (',',COLUMN_NAME) COLUMN_NAME , case when t.data_TYPE in('varchar','text') then 'string' when t.data_TYPE = 'decimal' then t.COLUMN_TYPE when t.data_TYPE = 'datetime' then 'timestamp' when t.data_TYPE = 'float' then 'double' else t.data_TYPE end data_TYPE , concat('comment ''',COLUMN_COMMENT,'''') COLUMN_COMMENT , concat ('{"name":"',COLUMN_NAME,'","type":"' , case when t.data_TYPE in('varchar','text') then 'string' when t.data_TYPE in('decimal', 'float') then 'double' when t.data_TYPE in('datetime') then 'timestamp' when t.data_TYPE in('tinyint','smallint') then 'int' else t.data_TYPE end ,'"},') data_TYPE from information_schema.columns t where TABLE_NAME = 'mk_event_popup_record' and TABLE_SCHEMA = 'cloud_cube_marketing' ; -- 自动生成select语句 select concat ('select ',group_concat( case when DATA_TYPE ='datetime' then concat('date_format(',COLUMN_NAME,',''%Y-%m-%d %H:%i:%s'') ',COLUMN_NAME ) else COLUMN_NAME end order by ORDINAL_POSITION),' from ',table_name) from information_schema.columns t where TABLE_NAME = 'mk_event_popup_record' and TABLE_SCHEMA = 'cloud_cube_marketing'
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
2021-05-31 006.php-phpstudy启动、php的目录位置查看、浏览器测试
2021-05-31 000.软考-高级-信息项目管理师的总结2021.05.29