Open baohongfei opened 7 years ago
-- Hive元数据表结构详解
-- 存储Hive版本的元数据表
-- 如果该表出现问题,根本进入不了Hive-Cli。比如该表不存在,当启动Hive-Cli时候,就会报错”Table ‘hive.version’ doesn’t exist”。
select * from VERSION;
-- 该表存储Hive中所有数据库的基本信息,字段如下:
select * from DBS;
select DB_ID,'DESC', DB_LOCATION_URI,NAME,OWNER_NAME,OWNER_TYPE from DBS;
-- 该表存储数据库的相关参数,在CREATE DATABASE时候用WITH DBPROPERTIES(property_name=property_value, …)指定的参数。
-- DBS和DATABASE_PARAMS这两张表通过DB_ID字段关联。
select * from DATABASE_PARAMS;
-- 该表中存储Hive表,视图,索引表的基本信息
select * from TBLS;
select distinct(tbl_type) from TBLS;
select * from TBLS where tbl_name = 'xx';
-- 该表存储表/视图的属性信息
select * from TABLE_PARAMS where TBL_ID in(select TBL_ID from TBLS where tbl_name = 'xx' and owner = 'xx');
-- 该表存储表/视图的授权信息
select * from TBL_PRIVS where TBL_ID in(select TBL_ID from TBLS where tbl_name = 'xx' and owner = 'xx');
-- Hive文件存储信息相关的元数据表
-- 主要涉及SDS、SD_PARAMS、SERDES、SERDE_PARAMS,由于HDFS支持的文件格式很多,而建Hive表时候也可以指定各种文件格式,
-- Hive在将HQL解析成MapReduce时候,需要知道去哪里,使用哪种格式去读写HDFS文件,而这些信息就保存在这几张表中。
-- 该表保存文件存储的基本信息,如INPUT_FORMAT、OUTPUT_FORMAT、是否压缩等。TBLS表中的SD_ID与该表关联,可以获取Hive表的存储信息。
select * from SDS where SD_ID in(select SD_ID from TBLS where tbl_name = 'xx' and owner = 'xx');
-- 该表存储Hive存储的属性信息,在创建表时候使用STORED BY ‘storage.handler.class.name’ [WITH SERDEPROPERTIES (…)指定。
select * from SD_PARAMS;
-- 该表存储序列化使用的类信息
select * from SERDES;
-- 该表存储序列化的一些属性、格式信息,比如:行、列分隔符
select * from SERDE_PARAMS;
-- 该表存储表对应的字段信息
select * from COLUMNS_V2 WHERE CD_ID = '5425639';
-- 该表存储表分区的基本信息
select * from PARTITIONS;
-- 该表存储分区的字段信息
select * from PARTITION_KEYS;
-- 该表存储分区字段值
select * from PARTITION_KEY_VALS;
-- 该表存储分区的属性信息
select * from PARTITION_PARAMS;
-- 数据库权限信息表。通过GRANT语句对数据库授权后,将会在这里存储。
select * from DB_PRIVS;
-- 索引表,存储Hive索引相关的元数据
select * from IDXS;
-- 索引相关的属性信息
select * from INDEX_PARAMS;
-- 表字段的统计信息。使用ANALYZE语句对表字段分析后记录在这里
select * from TAB_COL_STATS;
-- 表字段的授权信息
select * from TBL_COL_PRIVS;
-- 分区的授权信息
select * from PART_PRIVS;
-- 分区字段的权限信息
select * from PART_COL_PRIVS;
-- 分区字段的统计信息
select * from PART_COL_STATS;
-- 用户注册的函数信息
select * from FUNCS;
-- 用户注册函数的资源信息
select * from FUNC_RU;
select * from bhtest;
select * from BUCKETING_COLS;
select * from CDS;
select * from COMPACTION_QUEUE;
select * from COMPLETED_TXN_COMPONENTS;
select * from DELETEME1447244181098;
select * from DELETEME1450943692767;
select * from DELETEME1469154847709;
select * from DELETEME1471071641670;
select * from DELETEME1473058764384;
select * from DELETEME1473821490948;
select * from DELETEME1475894346243;
select * from GLOBAL_PRIVS;
select * from HIVE_LOCKS;
select * from NEXT_COMPACTION_QUEUE_ID;
select * from NEXT_LOCK_ID;
select * from NEXT_TXN_ID;
select * from NOTIFICATION_LOG;
select * from NOTIFICATION_SEQUENCE;
select * from ROLES;
select * from ROLE_MAP;
select * from SEQUENCE_TABLE;
select * from SKEWED_COL_NAMES;
select * from SKEWED_COL_VALUE_LOC_MAP;
select * from SKEWED_STRING_LIST;
select * from SKEWED_STRING_LIST_VALUES;
select * from SKEWED_VALUES;
select * from SORT_COLS;
select * from TXNS;
select * from TXN_COMPONENTS;