hive rename external table and column name

Опубликовано: 12 Октябрь 2024
на канале: Sreyobhilashi IT
468
3

in this video how to alter table name and change column name in HIve
create external table banktab (age int, job string, marital string, education string, default1 string, balance int, housing string, loan string, contact string, day string, month string, duration string, campaign string, pdays string, previous string, poutcome string, y string)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
"separatorChar" = ";",
"quoteChar" = "\""
)
LOCATION "s3://venusparkpoc2022/input/bank/"
tblproperties ("skip.header.line.count"="1") ;


#rename table name
ALTER TABLE banktab SET TBLPROPERTIES('EXTERNAL'='FALSE');


ALTER TABLE banktab RENAME TO banktab1


#rename column name and type
ALTER TABLE banktab1 CHANGE age myage string;

SET hive.metastore.disallow.invalid.col.type.changes=true;
set hive.metastore.disallow.incompatible.col.type.changes=true;

ALTER TABLE banktab1 SET TBLPROPERTIES('EXTERNAL'='TRUE');