
说明
1、通过hive的元数据库(通常为Msyql)获得,通过sql的关联即可。
2、获取表名称及表创建时间、库名及库注释,以S_ID作为关联关系获取C_ID,字段名称及字段注释在表中。
实例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | SELECT
t2.` NAME ` `database_name`,
t2.` DESC ` `database_comment`,
t1.`TBL_NAME` `table_name`,
t3.`PARAM_VALUE` `database_commet`,
FROM_UNIXTIME(t1.`CREATE_TIME`) `table_create_time`,
t5.`COLUMN_NAME` `column_name`,
t5.`COMMENT` `column_comment`,
t5.`TYPE_NAME` `column_data_type`
FROM
tbls t1
JOIN
dbs t2
ON
t1.DB_ID = t2.DB_ID
JOIN
(
SELECT
TBL_ID,
PARAM_KEY,
PARAM_VALUE
FROM
table_params
WHERE
PARAM_KEY = 'comment'
) t3
ON
t1.TBL_ID = t3.TBL_ID
JOIN
sds t4
ON
t1.SD_ID = t4.SD_ID
JOIN
columns_v2 t5
ON
t4.CD_ID = t5.CD_ID
|
以上就是mysql获取hive表的元数据信息,希望对大家有所帮助。更多mysql学习指路:MySQL
推荐操作系统:windows7系统、mysql5.8、DELL G3电脑