1 创建一个分区表

create table t_partition001(ip string,duration int)
partitioned by(country string)
row format delimited
fields terminated by ',';

2 添加数据

load data local inpath '/root/hivedata/t_partitioned' into table t_partition001 partition(country="China");

大数据学习——hive数仓DML和DDL操作

大数据学习——hive数仓DML和DDL操作

 

3 增加一个分区

alter table t_partition001 add partition(country="Japan");

4添加数据

 load data local inpath '/root/hivedata/t_partitioned' into table t_partition001 partition(country="Japan");

大数据学习——hive数仓DML和DDL操作

 

 5  show partitions t_partition001;

大数据学习——hive数仓DML和DDL操作

6删除分区

 alter table t_partition001 drop partition(country="Japan");大数据学习——hive数仓DML和DDL操作

7修改表名

 alter table t_partition001 rename to t_partition002;

8表增加一列

 alter table t_partition002 add columns(city string);

 

大数据学习——hive数仓DML和DDL操作

9 替换表中所有字段

alter table t_partition002 replace columns(name string);

大数据学习——hive数仓DML和DDL操作

 

 10 更新某一列

大数据学习——hive数仓DML和DDL操作

 

相关文章:

  • 2021-09-09
  • 2021-01-04
  • 2022-02-01
  • 2021-08-06
  • 2022-03-09
  • 2022-02-16
  • 2021-04-10
猜你喜欢
  • 2021-11-19
  • 2021-09-12
  • 2021-12-14
  • 2021-05-11
  • 2021-12-27
  • 2021-08-14
相关资源
相似解决方案