【问题标题】:how to alter schema by inserting a new column in hive如何通过在 hive 中插入新列来更改架构
【发布时间】:2017-02-25 21:04:50
【问题描述】:

我有一个存储在集群上的配置单元表。我想通过添加一个新列来修改它,并将旧列数据与从另一个表添加的新列的数据。有没有办法在不重新创建表的情况下做到这一点?

旧架构如下所示:

create external table XXX
(item_id bigint,
start_dt string,
end_dt string,
title string,
subtitle string,
description string)
row format delimited fields terminated by '\t' lines terminated by '\n'
stored as textfile
location '/user/me/XXX';

【问题讨论】:

    标签: hive alter-table


    【解决方案1】:

    你应该可以使用下面的语法来做到这一点。

    ALTER TABLE table_name 
      [PARTITION partition_spec]                 -- (Note: Hive 0.14.0 and later)
      ADD|REPLACE COLUMNS (col_name data_type [COMMENT col_comment], ...)
      [CASCADE|RESTRICT] -- (Note: Hive 0.15.0 and later)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-13
      • 1970-01-01
      • 1970-01-01
      • 2021-12-03
      相关资源
      最近更新 更多