hive加载数据和导出数据
来源:互联网 发布:icsd数据库网址 编辑:程序博客网 时间:2024/06/06 02:05
1.hive加载数据
1.1、load方式加载数据
两种:1、load data local inpath "/home/hadoop/student.txt" into table student;
2、load data inpath "/appstudent/student.txt" into table student;
3、hadoop fs -put /home/hadoop/student.txt /user/hive/warehouse/myhive.db/student
1.2、insert方法加载数据
五种:1、单个insert插入
insert into table (id, name , sex, age ,department) values (1,2,3,4,5),(1,2,3,4,5);
2、insert .... select ....
insert into table (id, name, sex, age, department) select id,name, sex,age, department from student;
3、多重插入
from student
insert into table ptn_student partition (department = 'CS') select * where department = 'CS'
insert into table ptn_student partition (department = 'IS') select * where department = 'IS'
4、分区插入
分两种:
1、静态分区插入
先添加分区:alter table ptn-student add partition (city="bj");
加载数据;load data local inpath "studnet.txt" into table pnt_student parition(city="bj");
2、动态分区
两个条件:
1、开启动态分区的开关
set hive.exec.dynamic.partition=true;
2、默认的动态分区的模式为严格模式
在严格模式下,进行动态分区插入要求至少要有一列静态分区,并且静态分区必须在前面
set hive.exec.dynamic.partition.mode = nonstrict;
动态分区插入的语句:
insert into table ptn_student partition(city) select id,name,sex,city from student;
注意:动态分区的字段必须是select的最后一个字段
2.insert方式导出数据
分两种:1、导出到本地;
insert overwrite local direcotry "/home/hadoop/appstudent" select * from student;
2、导出到HDFS:
insert overwrite direcotry "/appstudent" select * from student;
insert overwrite direcotry "hdfs://hadoop02:9000/appstudent" select * from student;
3、hive表的数据进行备份:
export : 导出备份
import : 载入备份
阅读全文
0 0
- hive加载数据和导出数据
- Hive中数据的加载和导出
- Hive中数据的加载和导出
- Hive中数据的加载和导出
- Hive数据导入和导出
- hive导入和导出数据
- Hive数据导入和导出
- Hive的数据导入导出,插入,加载
- Hive 表数据 加载 、导出 、查询
- 十七、Hive 表数据加载、导出、查询
- hive数据的加载与导出
- Hive数据的导入和导出
- hive数据导出
- Hive 导入导出数据
- hive数据导出
- hive数据导入导出
- Hive数据导出
- hive 导入导出数据
- POJ 2406 kmp求解循环节
- 关于响应式的一点总结
- HTML5-jqUI----EasyUI
- PHP去掉头信息
- 剑指offer:第一次只出现一次的字符
- hive加载数据和导出数据
- vim全局,局部查找 替换字符串
- 旋转卡壳
- SQL语言学习框架
- 我如何选择了流行的PHP
- Java 泛型
- 算法题/奇怪的表达式求值
- Plugin Error: Android ButterKnife Zelezny threw an uncaught ArrayIndexOutOfBoundsException. Disable
- 5-37 模拟EXCEL排序 (c++结构体快排)