方法:
先增加字段,然后再移动字段。

alter table tbl_1 add columns(col_c string comment'ccc') ;
alter table tbl_1 change col_c col_c string comment'cccc' after col_b;

具体代码如下:

1. 创建表
create table tbl_1(
  col_a string comment'aaa'
, col_b string comment'bbb'
, col_d string comment'ddd'
) comment'test'
;

查看表结构
desc tbl_1 ;

顺序:
a
b
d

2. 增加字段
alter table tbl_1 add columns(col_c string comment'ccc') ;

查看表结构
desc tbl_1 ;

顺序:
a
b
d
c

3. 移动新增的字段
alter table tbl_1 change col_c col_c string comment'cccc' after col_b;

查看表结构
desc tbl_1 ;

顺序:
a
b
c
d

相关文章:

  • 2021-12-31
  • 2021-07-06
  • 2022-02-19
  • 2021-12-16
  • 2021-12-24
  • 2021-12-07
  • 2021-11-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-24
  • 2021-12-21
  • 2022-01-24
  • 2021-12-03
相关资源
相似解决方案