datatablehivesizevarcharhiveddl

Hive Alter table column size in VARCHAR


I am pretty new in Hive and I have created a table below few months ago

create table TableName 
(
    EntityRelationship varchar(20), 
    EntityID varchar(50), 
    EntityName varchar(50), 

    CLUSTERED BY (EntityID) INTO 60 BUCKETS STORED AS ORC
)

However, now I have realized EntityName Varchar(50) is not enough it needs to be Varchar(250). I found alter table codes but all of them are not changing the size of the column but change types and names.

Also I can not DROP the table as it already have lots of data and that means I have to reload past months daily.

What I want the end table to be described like below

create table TableName 
( 
    EntityRelationship varchar(20), 
    EntityID varchar(50), 
    EntityName varchar(250), 
    CLUSTERED BY (EntityID) INTO 60 BUCKETS STORED AS ORC
)

Is there away I can alter this existing table going forward to EntityName varchar(250) without dropping the table? Appreciate your time. Thanks


Solution

  • ALTER TABLE TableName CHANGE COLUMN EntityName EntityName  varchar(250);
    

    Read more details: Change Column Name/Type/Position/Comment