Hive: Alter a Table to New Location

 25th August 2021 at 1:05pm

Hive 外部表改名、改 location:

ALTER TABLE old_tablename RENAME TO new_tablename;

ALTER TABLE tablename SET LOCATION 'hdfs:///path/to/new/location';

-- 注意:修改 location 后需要运行 MSCK REPAIR TABLE。如果表带有分区,还需要带上 SYNC PARTITIONS
MSCK REPAIR TABLE tablename SYNC PARTITIONS;