本文中主要是介绍了hive中索引和视图的相关操作。
修改表主要是对表的结构和属性进行操作,包含:
alter table oldname rename to new_table;alter table table_name set tblproperties (property_name=property_value);alter table table_name set tblproperties('comment'=new_comment);alter table table_name clustered by (col_name, col_name,...) [sorted by (col_name,...)] into number buckets;alter table tablename add [if not exists] partition partition_spec [location 'location1'] partion_spec [location 'location2']...alter table tablename partition partition_spec rename to partition partition_spec;alter table table_name1 exchange partition (partition-spec1, partition-spec2) with table table_name2;msck repair table tablename;alter table tablename drop [if exists] parition partition-spec [ignore protection] [purge];alter table tablename archive partition partition-spec; -- 归档
alter table tablename unarchive partition partition-spec; -- 解档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; -- 下线状态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];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')