Hive表结构操作(增加列,删除列,修改列,移动列)

前言

Hive 表结构操作

内容

1.给hive表中添加某个字段

格式:

alter table 表名 add columns (字段名 字段类型 comment '字段描述')

示例1:

alter table table_name add columns (now_time string comment '当前时间');

示例2:

alter table table_name add columns (now_time varchar(300) comment '当前时间');

2.个体hive表中指定位置添加字段
步骤:先添加字段到最后 ,然后再移动到指定位置

alter table table_name add columns (c_time string comment '当前时间');  添加到最后
alter table table_name change c_time c_time string after giao;  移动到指定位置,giao后面

3.修改hive表的名字
格式:

ALTER TABLE table_name CHANGE 旧列名 新列名 字段类型;

示例:

alter table giao change id taskid varchar(300);

4.修改hive表的名:

alter table name rename to new_Name;

5.修改表的备注:

ALTER TABLE 数据库名.表名 SET TBLPROPERTIES('comment' = '新的表备注');

6.删除Hive表中某个字段:

create table giao(
a string,
b string,
c string,
d string,
e bigint,
f bigint,
f int
);

删除 f 列 :

ALTER TABLE test REPLACE COLUMNS (
a string,
b bigint,
c string,
d string,
e bigint
);

总结

Hive表结构操作(增加列,删除列,修改列,移动列)

  • 2
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值