大数据之Hive:DML数据操作(二)

数据导入(增)
3.查询语句中创建表并加载数据(As Select)

create table if not exists student3
as select id, name from student;

4.创建表时通过Location指定加载数据路径
1.上传数据到hdfs上

hive (default)> dfs -mkdir /student;
hive (default)> dfs -put /opt/module/datas/student.txt /student;

2.创建表,并指定在hdfs上的位置

hive (default)> create external table if not exists student5(
              id int, name string
              )
              row format delimited fields terminated by '\t'
              location '/student';

3.查询数据

hive (default)> select * from student5;

5 .Import数据到指定Hive表中
注意:先用export导出后,再将数据导入。

hive (default)> import table student2 partition(month='201709') from
 '/user/hive/warehouse/export/student';

6.Sqoop导入

猜你喜欢

转载自blog.csdn.net/weixin_43597208/article/details/112553948
今日推荐