Sherry IT Blog

알아두면 유용한 Hive alter문 본문

BIgData

알아두면 유용한 Hive alter문

sherrylover 2021. 2. 2. 16:39
728x90
반응형
-- 1.컬럼변경
alter table 테이블명 change [old_column] [new_column] new_column_type

-- 2.컬럼추가
alter table 테이블명 add columns([new_column] [new_column_type] comment [comment_name])

--(comment 생략가능)

-- 3. 컬럼삭제
alter table 컬럼명 replace colums(남겨둘컬럼 컬럼타입,남겨둘컬럼2 컬럼타입2 .......)

(컬럼갯수가 많다면 create 가 더 효율적일 수 있음)

-- 4.테이블명 변경

alter table 테이블명 rename to 새테이블명

-- 5.테이블 코멘트 추가하기

alter table 테이블명 set tblproperties('comment' = '코멘트명')

-- 6.테이블 파티션 타입 변경
alter table 테이블명 partition column (파티션명 파티션타입)

--ex) alter table test.test partition column( year string, month string)
728x90
반응형
Comments