본문 바로가기

SQL/hive

[hive] table, column add comment / add column / change column order / column rename

table comment add

ALTER TABLE table_name SET TBLPROPERTIES ('comment' = new_comment);

 

column comment add

ALTER TABLE table_name CHANGE col1 col1 colType COMMENT 'new_comment';

 

파티션 컬럼은 테이블생성시에만 코멘트를 추가할 수 있다.

Comment can be added to a partition column at the time of creation of the table.

HUE > Table Browser > edit 가능

 

change column order

ALTER TABLE tmp.table_name CHANGE col_name col_name col_type AFTER col_name2

 

column rename

ALTER TABLE tmp.table_name CHANGE col_old_name col_new_name col_type

ALTER TABLE table_name [PARTITION partition_spec] CHANGE [COLUMN] col_old_name col_new_name column_type

  [COMMENT col_comment] [FIRST|AFTER column_name] [CASCADE|RESTRICT];

 

컬럼추가

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 1.1.0 and later)

The CASCADE|RESTRICT clause is available in Hive 1.1.0. ALTER TABLE ADD|REPLACE COLUMNS with CASCADE command changes the columns of a table's metadata, and cascades the same change to all the partition metadata. RESTRICT is the default, limiting column changes only to table metadata.

'SQL > hive' 카테고리의 다른 글

[hive] partition add / delete  (0) 2020.06.04
[hive] partition column rename  (0) 2020.06.03
[hive] table rename , change location  (0) 2020.06.01