0
点赞
收藏
分享

微信扫一扫

MySQL元数据信息映射 Hive 表字段信息

SELECT 
CONCAT(colname,' ',data_type,' ',COMMENT_zh,' ',splitCharacter) as colnameddl
from
(
select
DISTINCT
*
from (

select
a.TABLE_SCHEMA,
a.table_comment,
b.table_name,
concat('`', b.column_name, '`') colname,
case
when b.NUMERIC_PRECISION is not null and
(b.data_type = 'decimal' or b.data_type = 'numeric') then
concat('decimal(', b.NUMERIC_PRECISION, ',', b.NUMERIC_SCALE, ')')
when (b.CHARACTER_MAXIMUM_LENGTH is not null or
b.data_type = 'uniqueidentifier') and
b.data_type not like '%text%' then
'string'
when b.data_type in ('datetime','date','timestamp','text','longtext') then
'string'
when data_type = 'money' then
'decimal(50,4)'
when b.data_type in ('tinyint','int') then
'bigint'
else
data_type
end as data_type,
concat('comment', ' \'',b.COLUMN_COMMENT,'\'') as COMMENT_zh,
',' as splitCharacter
from information_schema.TABLES a LEFT join information_schema.columns b ON a.table_name=b.TABLE_NAME and a.TABLE_SCHEMA= b.TABLE_SCHEMA

)xx
) t1 where TABLE_SCHEMA='dlink' and table_name = 'dlink_user'

结果如下: 

MySQL元数据信息映射 Hive 表字段信息_hive

举报

相关推荐

0 条评论