Hive orc表 删除字段

在Hive中删除ORC表的字段无法直接操作,必须使用REPLACE COLUMNS关键字。若表不是外部表,需先将其设置为外部表,然后删除表并根据新Schema重建,以实现字段删除。
摘要由CSDN通过智能技术生成
说明

Unfortunately, you can’t! (很不幸,不能这么操作)
The only way you can delete column from existing table is by using REPLACE COLUMNS keyword.
But this can be done only for tables with a native SerDe (DynamicSerDe, MetadataTypedColumnsetSerDe, LazySimpleSerDe and ColumnarSerDe).

Your best bet is recreating the schema. Follows the steps.(建议重新建Schema)

  1. Check if the table is external. If it isn’t, use the following statement to make it external.

  2. alter table alpha001 set tblproperties(‘EXTERNAL’=‘TRUE’);
    Drop the table. Since the table is an external table, you can drop it without dropping the actual table.

  3. Recreate the table with the new schema. You should be able to access the table with new schema.

解决例子
原始表结构
create external table if not exists ods_mysql.ods_db_o2m__tb_time_period_dict ( 
    `id` bigint comment "自增ID",
    
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值