Hive alter table drop column 失败 mismatched input 'column' expecting PARTITION near 'DROP' in drop pa

本文详细解释了在SQL中直接使用ALTERTABLE命令删除列时遇到的错误,并提供了一种解决方案,即使用REPLACECOLUMNS命令来间接实现删除列的目的。通过一个具体的例子,展示了如何从包含id、name和dept列的emp表中删除id列。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ALTER TABLE aaa DROP column (name);

失败:

 

语法校验失败!

line 1:49 mismatched input 'column' expecting PARTITION near 'DROP' in drop partition statement

原因及解决方法:

http://www.it1352.com/842613.html

 

You cannot drop column directly from a table using command ALTER TABLE table_name drop col_name;

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);

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值