Hive表 增改删字段

基本语法:

ALTER TABLE name RENAME TO new_name
ALTER TABLE name ADD COLUMNS (col_spec[, col_spec ...])
ALTER TABLE name DROP [COLUMN] column_name
ALTER TABLE name CHANGE column_name new_name new_type
ALTER TABLE name REPLACE COLUMNS (col_spec[, col_spec ...])
refer: https://www.yiibai.com/hive/hive_alter_table.html


自己实验:

1. alter table d_extra.dm_usr_mxdai_risk_analysis add columns(test1 int, test2 int);   ------works

    desc d_extra.dm_usr_mxdai_risk_analysis; 

   可以看出新字段已经添加成功

1.1. alter table d_extra.dm_usr_mxdai_risk_analysis add column test1 int; ------doesn't work



2. alter table d_extra.dm_usr_mxdai_risk_analysis drop column test1;  -----doesn't work

报错:

Error: Error while compiling statement: FAILED: ParseException line 1:52 mismatched input 'column' expecting PARTITION near 'drop' in drop partition statement (state=42000,code=40000)

是不是只能drop partition 而不能drop column??


3. alter table d_extra.dm_usr_mxdai_risk_analysis change test1 risk_1_138 string;  ------works

猜你喜欢

转载自blog.csdn.net/littlecarton/article/details/79390162