添加数据表分区partitions
alter table db_baseline_daily add partition (date_str='2019-02-26') location 's3://mob-emr-test/kylin/olap/db_baseline_daily/';
#
alter table db_baseline_daily add if not exists partition (date_str='2019-02-26') location 's3://mob-emr-test/kylin/olap/db_baseline_daily/';
删除数据表分区paritions
alter table db_baseline_daily drop partition (date_str='2019-02-26');
#
alter table db_baseline_daily drop if exists partition (date_str='2019-02-26');
添加列
ALTER TABLE table_name ADD COLUMNS (col_name STRING);
删除列
ALTER TABLE table_name DROP COLUMNS (col_name STRING);
修改列
CREATE TABLE test_change (a int, b int, c int);
// will change column a's name to a1
ALTER TABLE test_change CHANGE a a1 INT;
// will change column a's name to a1, a's data type to string, and put it after column b. The new table's structure is: b int, a1 string, c int
ALTER TABLE test_change CHANGE a a1 STRING AFTER b;
// will change column b's name to b1, and put it as the first column. The new table's structure is: b1 int, a string, c int
ALTER TABLE test_change CHANGE b b1 INT FIRST;
重命名表
ALTER TABLE table_name RENAME TO new_table_name
修改表属性
alter table table_name set TBLPROPERTIES ('EXTERNAL'='TRUE'); //内部表转外部表
alter table table_name set TBLPROPERTIES ('EXTERNAL'='FALSE'); //外部表转内部表











网友评论