Hive 基本操作-Table
1)更改表名
alter table 原表名 rename to 心表名;
示例:alter table bst_agg_new_car_hailing_order_model_d rename to bst_agg_car_hailing_order_model_d;
2)更改location
alter table 原表 set location 'loaction地址'
示例:alter table bst_bas_hailing_order_amount set location 'hdfs://nameservice1/user/hive/external/tables/bas/bst_car_center/dw_car_hailing/bst_bas_hailing_order_amount'
3)更改字段名称、字段类型
alter table 表名 change column 原字段名称 现字段名称 数据类型
示例:
alter table bst_bas_hailing_order_amount change column state order_state string 更改字段名称
alter table bst_bas_hailing_order_amount change column state state string 更改字段类型
4)添加字段注释
alter table bst_bas_hailing_order_his change column reserved reserved string comment '是否预叫单,0否1是'
5)添加表字段
alter table bst_agg_new_car_hailing_order_model_d add columns(reserved string,proxyed string);
6)更改字段分隔符
alter table bst_bas_hailing_order_amount set SERDEPROPERTIES('field.delim'='\t');
7)修改内部表为外部表
alter table student set tblproperties('EXTERNAL'='TRUE');
8)修改外部表为内部表
alter table student set tblproperties('EXTERNAL'='FALSE');
9)给表加注释或者修改表的注释
alter table table_name set tblproperties('comment' = '表的新注释');
#注意comment是小写的,必须加引号

浙公网安备 33010602011771号