首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >hive之路9-hive索引和视图

hive之路9-hive索引和视图

作者头像
皮大大
发布2021-03-02 16:10:07
发布2021-03-02 16:10:07
8150
举报

本文中主要是介绍了hive中索引和视图的相关操作。

修改表

修改表主要是对表的结构和属性进行操作,包含:

  • 重命名
代码语言:javascript
复制
alter table oldname rename to new_table;
  • 修改表属性
代码语言:javascript
复制
alter table table_name set tblproperties (property_name=property_value);
  • 修改表注释
代码语言:javascript
复制
alter table table_name set tblproperties('comment'=new_comment);
  • 修改存储属性
代码语言:javascript
复制
alter table table_name clustered by (col_name, col_name,...) [sorted by (col_name,...)] into number buckets;
  • 修改表的目录

修改分区

  • 添加分区
代码语言:javascript
复制
alter table tablename add [if not exists] partition partition_spec [location 'location1'] partion_spec [location 'location2']...
  • 重命名分区
代码语言:javascript
复制
alter table tablename partition partition_spec rename to partition partition_spec;
  • 交换分区
代码语言:javascript
复制
alter table table_name1 exchange partition (partition-spec1, partition-spec2) with table table_name2;
  • 修复分区
代码语言:javascript
复制
msck repair table tablename;
  • 删除分区
代码语言:javascript
复制
alter table tablename drop [if exists] parition partition-spec [ignore protection] [purge];
  • 解档和归档
代码语言:javascript
复制
alter table tablename archive partition partition-spec;  -- 归档
alter table tablename unarchive partition partition-spec;  -- 解档
  • 修改文件格式、路径、保护
代码语言:javascript
复制
alter table tablename [partition partition-spec] set fileformat file_format;

alter table tablename [partition partition-spec] set location "new-location";

alter table tablename [partition partition-spec] enable|disable no-drop [cascade];  -- 保护:不能删除

alter table tablename [partition partition-spec] enable|disable offline;  -- 下线状态

修改字段

  • 修改属性、位置、注释等
代码语言:javascript
复制
alter table tablename [partition partition-spec] change [column] col_old_name col_new_name column_type [comment col_comment] [first|after column_name] [cascade|restrict];
  • 增加和替换列
代码语言:javascript
复制
alter table tablename [partition partition-spec] add|replace columns(col_name data_type [comment col_comment],...)

-- demo:增加sex字段,指定注释
alter table student add columns (sex string comment 'sex of student')
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-11-23,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 修改表
  • 修改分区
  • 修改字段
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档