[Hive] Alter

less than 1 minute read


Alter

-- alter table schema
alter table table2 add columns (col5 string); -- 특별히 저 col5에 해당되는 data를 지정해주지 않는 이상 NULL 값이 들어가게 됨

-- check result
describe table2;
describe extended table2;
describe formatted table2;

-- change name of column
alter table wales change column col3 country_name string;

-- rename table
alter table wales rename to wales2;

-- removing columns, ()안에 명시된 column만 남게 됨, 이 경우 col4만 table2안에 남게 됨
alter table table2 replace columns(col4 int);

-- alter table properties
alter table england set tblproperties('auto.purge'='true');
alter table england set fileformat avro;

Tags:

Categories:

Updated: