首页 > 数据库技术 > 详细

mysql表结构转hive表结构,字段映射脚本

时间:2020-03-11 19:24:27      阅读:359      评论:0      收藏:0      [点我收藏+]

按照以下脚本执行,导出txt文件即可得到相应的hive字段映射。

select concat(`, column_name, `) colname,
       case
         when NUMERIC_PRECISION is not null and
              (data_type = decimal or data_type = numeric) then
          concat(decimal(, NUMERIC_PRECISION, ,, NUMERIC_SCALE, ))
         when (CHARACTER_MAXIMUM_LENGTH is not null or
              data_type = uniqueidentifier) and
              data_type not like %text% then
          string
         when data_type = datetime then
          timestamp
         when data_type = money then
          decimal(9,2)
         when data_type = tinyint then
          int
         else
          data_type
       end as data_type,
       concat(comment,  \‘‘,COLUMN_COMMENT, ‘‘) as comment,
        , as splitCharacter
  from information_schema.columns
 where table_name = xxxxxxxxxx

 

mysql表结构转hive表结构,字段映射脚本

原文:https://www.cnblogs.com/lianshan/p/12463980.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!