Hive 元数据库操作 Hive 元数据库操作是 Hive 运维中常用的操作之一,它提供了对元数据的管理和查询功能。在 Hive 中,元数据是指对数据的描述信息,如表名、表路径、分区信息、列信息等。下面将对 Hive 元数据库操作的常用 SQL 语句进行逐一解释。 查看表名及其对应的路径 查看表名及其对应的路径可以使用以下 SQL 语句: ```sql drop view v_table_path; create view v_table_path as select c.name, b.db_id, tbl_name, location, b.tbl_id, b.tbl_type, date_format(from_unixtime(b.create_time),'%Y%m%d') create_time from SDS a, TBLS b, DBS c where a.sd_id=b.sd_id and b.db_id=c.db_id; ``` 查看表是否有分区 查看表是否有分区可以使用以下 SQL 语句: ```sql select a.tbl_name, case when b.tbl_id is null then 'N' else 'Y' end is_parted from TBLS a left join (select distinct tbl_id from PARTITION_KEYS) b on a.tbl_id=b.tbl_id order by 1; ``` 查看表的分区及其对应的路径 查看表的分区及其对应的路径可以使用以下 SQL 语句: ```sql drop view v_table_part_path; create view v_table_part_path as select d.name, a.tbl_name, b.part_name, c.location, a.tbl_type, date_format(from_unixtime(b.create_time),'%Y%m%d') create_time from TBLS a, PARTITIONS b, SDS c, DBS d where a.tbl_id=b.tbl_id and b.sd_id=c.sd_id and a.db_id=d.db_id; ``` 查看非分区表的路径 查看非分区表的路径可以使用以下 SQL 语句: ```sql select a.name, a.tbl_name, a.location from v_table_path a left join (select distinct tbl_id from PARTITION_KEYS) b on a.tbl_id=b.tbl_id where b.tbl_id is null; ``` 查看表的列 查看表的列可以使用以下 SQL 语句: ```sql select a.tbl_id, a.sd_id, c.cd_id, tbl_name, c.* from TBLS a, SDS b, COLUMNS_V2 c where a.sd_id=b.sd_id and b.cd_id=c.cd_id and tbl_name='t_ed_mtt_func_profile' order by INTEGER_IDX; ``` 查看表的分区字段 查看表的分区字段可以使用以下 SQL 语句: ```sql select a.tbl_id, a.sd_id, tbl_name, p.pkey_name, pkey_type, p.INTEGER_IDX from TBLS a, SDS b, PARTITION_KEYS p where a.sd_id=b.sd_id and a.tbl_id=p.tbl_id and tbl_name='t_od_qqbook_kernel_access' order by INTEGER_IDX; ``` 查看表的字符集 查看表的字符集可以使用以下 SQL 语句: ```sql select a.tbl_name, c.* from TBLS a, SDS b, SERDE_PARAMS c where a.sd_id=b.sd_id and b.SERDE_ID=c.SERDE_ID and c.PARAM_KEY='charset' and PARAM_VALUE='gbk'; ``` 查看字符分隔符 查看字符分隔符可以使用以下 SQL 语句: ```sql select b.part_name, d.PARAM_VALUE from TBLS a, PARTITIONS b, SDS c, SERDE_PARAMS d where a.tbl_id=b.tbl_id and b.sd_id=c.sd_id and c.SERDE_ID=d.SERDE_ID and d.PARAM_KEY='field.delim' and a.tbl_name like 't_sh_qqpim_softusageinfoserver'; ``` Hive 元数据库操作提供了多种方式来查询和管理元数据,开发者可以根据实际需要选择合适的 SQL 语句来实现相应的操作。
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
- 粉丝: 0
- 资源: 1
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)