create table t1(
c1 string,
c2 string
);
create table t2(partitioned by ( c2 string ) # 创建分区 c1跟c2都是字段,但是创建的时候不能写在t2里面,只能写在分区里面(同时select查询的时候,c2的字段也要写在最后面)
c1 string
) partitioned by ( c2 string ) row format delimited fields terminated by ',';
load data inpath '/lyh/bbb.txt' into table t2 partition (c2='a');
msck repair table t2;
select * from t2;
hdfs dfs -mkdir /user/hive/warehouse/test1118.db/t2/b
hdfs dfs -put /a.txt /user/hive/warehouse/test1118.db/t2/b
进入hive 后使用命令
use test1118;
load data inpath '/lyh/a.txt' into table t2 partition(c2='b');
msck repair table t1;
select * from t2;
create table t3 (
id int,
name string
)partitioned by (year string,month string)
row format delimited fields terminated by ',';
load data inpath '/lyh/a.txt' into table t3 partition (year='2022',month='11');
select * from t3 where year='2022';
select * from t3 where year='2022' and month='11';
hdfs dfs -mkdir /user/hive/warehouse/test1118.db/t3/year
hdfs dfs -mkdir /user/hive/warehouse/test1118.db/t3/year/month
hdfs dfs -mkdir -p /user/hive/warehouse/test1118.db/t3/2023这里的-p和linux意义不同
hdfs dfs -mkdir -p /user/hive/warehouse/test1118.db/t3/2023/11
hdfs dfs -put /a.txt /user/hive/warehouse/test1118.db/t3/2023/11进入hive,然后输入 use dest1118;
msck repair table t3;
select * from t3;
alter table t3 add if not exists partition(year='2023',month='11');
hdfs dfs -mv /d.txt /user/hive/warehouse/test1118.db/t3进入hive,use test1118;
select * from t3;
set hive.exec.dynamic.partition=true
create database test1125;
use test1125;
create table t1(删除表
c1 string
) partitioned by(c2 string)
row format delimited fields terminated by ',';
drop table t1;
create table t2(
id int,
name string
) partitioned by(year string,month string)
row format delimited fields terminated by ',';
create table t1(
title string,
author_name string,
dynasty string,
c1 string,
c2 string,
c3 string,
c4 string
) row format delimited fields terminated by ',';
create table t1(
title string,
author_name string,
dynasty string,
c1 string,
c2 string,
c3 string,
c4 string
)partitioned by ( c5 string ) row format delimited fields terminated by ',';
hdfs dfs -put a.txt /lyh
use test1125;
load data inpath '/lyh/a.txt' into table t1 partition(c5='a');
select * from t1;
免责申明:
本文系转载,版权归原作者所有,如若侵权请联系我们进行删除!
《数据治理行业实践白皮书》下载地址:https://fs80.cn/4w2atu
《数栈V6.0产品白皮书》下载地址:https://fs80.cn/cw0iw1
想了解或咨询更多有关袋鼠云大数据产品、行业解决方案、客户案例的朋友,浏览袋鼠云官网:https://www.dtstack.com/?src=bbs
同时,欢迎对大数据开源项目有兴趣的同学加入「袋鼠云开源框架钉钉技术群」,交流最新开源技术信息,群号码:30537511,项目地址:https://github.com/DTStack