1 修改表名
ALTER TABLE data_7day1 RENAME TO data_7day;
2 修改字段名
ALTER TABLE table_name CHANGE [COLUMN] col_old_name col_new_name column_type [COMMENT col_comment] [FIRST|AFTER column_name]
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;
ALTER TABLE sample_basic_7day CHANGE `_c1` cnt INT;
3 修改表分区
ALTER TABLE bdm.tmp_dp_positive PARTITION (days=4) RENAME TO PARTITION (days=5);
4 增加表分区
alter table sog.stage_originlog_lzo_appkey_dt add if not exists partition (appkey='a1',dt='d1') location 's3://hdfs/logs/a1/dt=d1';
5 增加表字段
ALTER TABLE test1 ADD COLUMNS (access_count1 int);
6 删除某个字段
The only way to drop column is using replace command. Lets say, I have a table emp with id, name and dept column. I want to drop id column of table emp. So provide all those columns which you want to be the part of table in replace columns clause. Below command will drop id column from emp table.
emp表有字段id, name, dept三个字段,如果要去掉字段id,则进行如下操作
ALTER TABLE emp REPLACE COLUMNS( name string, dept string);
04-03
1157
03-02
4922
04-30
1万+
02-16
2万+
09-11
2442
02-07
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交