更改配置单元表添加或删除列 [英] Alter hive table add or drop column

查看:2238
本文介绍了更改配置单元表添加或删除列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在配置单元中有orc表我想从这个表中删除列

I have orc table in hive I want to drop column from this table

ALTER TABLE table_name drop  col_name;

但我收到以下异常:

but I am getting the following exception


执行配置单元查询时发生错误:OK FAILED:ParseException行1:35不匹配输入'user_id1'期望分区语句中'drop'附近的PARTITION

Error occurred executing hive query: OK FAILED: ParseException line 1:35 mismatched input 'user_id1' expecting PARTITION near 'drop' in drop partition statement

任何人都可以帮我或提供任何想法来做到这一点吗?请注意,我是使用hive 0.14

Can any one help me or provide any idea to do this? Note, I am using hive 0.14

推荐答案

从表中使用命令> ALTER TABLE table_name drop col_name;

删除列的唯一方法是使用replace命令。可以说,我有一个表的emp与ID,名称和部门专栏。我想删除表emp的id列。因此,在替换列子句中提供您想要成为表的一部分的所有列。下面的命令将从emp表中删除id列。

The only way to drop column is using replace command. Lets say, I have a table emp with id, name and dept column. I want to drop id column of table emp. So provide all those columns which you want to be the part of table in replace columns clause. Below command will drop id column from emp table.

 ALTER TABLE emp REPLACE COLUMNS( name string, dept string);

这篇关于更改配置单元表添加或删除列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆