时间: 2020-09-19|57次围观|0 条评论

修改表名

alter table table_name rename to new_table_name

Hive的表属性操作插图

增加列

alter table tablename add columns(c1 string comment 'xxxx',
c2 long comment 'yyyy')

Hive的表属性操作插图1

修改列名

alter table tablename change column c_Old c_New int comment 'XXXXXX'

after severity;//可以把该列放到指定列的后而,或者使用’first’放到第一位。

Hive的表属性操作插图2

修改表属性tblproperties

alter table tablename set tblproperties( property_name=property_value,property_name=property_value,… );

Hive的表属性操作插图3

修改表属性serdeproperties

注意:针对无分区表与有分区表不同。

无分区

alter table tablename set serdeproperties( 'field.delim'='\t' );

Hive的表属性操作插图4

Hive的表属性操作插图5

有分区

alter table tablename partition(dt='xxxx') set serdeproperties ('field.delim'='\t');

Hive的表属性操作插图6

Hive的表属性操作插图7

修改location

布置只有外部表可以指定location,内部表也可以指定location。
alter table table_name [partition(...)] set location 'path'

Hive的表属性操作插图8

Hive的表属性操作插图9

Hive的表属性操作插图10

验证:
select * from city;
删除表同样也会将指定位置的文件目录删除。

内部表转外部表

alter table tablename set TBLPROPERTIES ('EXTERNAL' = 'TRUE');

外部表转内部表

alter table table_name set TBLPROPERTIES('EXTERNAL'='FALSE');

Hive的表属性操作插图11

Hive的表属性操作插图12

Hive的表属性操作插图13

原文链接:https://blog.csdn.net/scgaliguodong123_/article/details/46941419

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《Hive的表属性操作
   

还没有人抢沙发呢~