
苹果电脑支持对硬盘批量添加分区表分区。
教程:
1.插入一张准备批量分区的硬盘(SD卡、U盘、移动硬盘也行),打开苹果电脑自带的磁盘工具进行查看(见图中蓝色高亮部分)。
2.点击分区布局里的下拉列表框,将分区改成4个(也可以设置成其他数量,根据需求选择)。
3.点击应用按钮,选择分区开始对硬盘进行批量分区 *** 作。
1.创建二级分区表create table dept_aprtition2(deptno int,dname string ,loc string)
partitioned by (month string,day string)
row format delimited fields terminated by '\t'
2.正常的加载数据(用的最多)
(1)加载数据到二级分区表中
load data local inpath '/xx/xx/xx' into table dept_partition2 partiton(month='2019-05',day='13')
(2)查询分区数据
select * from dept_partiton2 where month='201905' and day='13'
3.把数据直接上传到分区目录上,让分区表和数据产生关联的三种方式
(1).方式一:上传数据后修复
上传数据
dfs -mkdir -p /user/hive/warehouse/dept_partition2/month=201909/day=09
dfs -put /xx/xx/xx /user/hive/warehouse/dept_partition2/month=201909/day=09
查询数据(查询不到刚上传的数据)
select * from dept_partition2 where month='201909' and day='09'
执行修复命令
msck repair table dept_partition2
再次查询数据
select * from dept_partition2 where month='201909' and day='09'
(2)方式二:上传数据后添加分区
上传数据
dfs -mkdir -p /user/hive/warehouse/dept_partition/month=201908/day=11
dfs -put /xxx/xxx/xx /user/hive/warehouse/dept_partition/month=201908/day=11
执行添加分区
alter table dept_partition2 add partition(month='201906' day='06')
查看数据
select * from dept_partition2 where month='201709' and day='11'
(3)方式三:创建文件夹后load数据到分区
创建目录
dfs -mkdir -p /usr/hive/warehouse/dept_partition2/month=201903/day=10
上传数据
load data local inpath '/xx/xx/xx' into table dept_partition2 partition(month='201903',day='10')
查看数据
select * from dept_partition2 where month='201903' and day='10'
1、创建语句create table p(id number)
partition by range(id)
(partition p1 values less than(100) tablespace t1,
partition p2 values less than(200) tablespace t2,
partition p3 values less than(300) tablespace t3)
2、添加分区
alter table p add partition p4 values less than (400) tablespace t4
3、清除分区数据
alter table p trunc partition p1
4、删除分区
alter table p drop partition p1
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)