修改表字段名以及表信息

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);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值