Hive基本操作(三)
来源:互联网 发布:java线程池例子 编辑:程序博客网 时间:2024/06/05 10:18
建表:内部表、外部表、分区表、桶表
内部表:
create table if not exists student(
id int,name string,age int,sex string
)row format delimited
fields terminated by "\t";
查看创建表的信息
show create table student;
查看表结构(列)信息
desc student;
导入数据方法一:
load data local inpath '/home/tg/datas/students' overwrite into table student;
外部表:
create external table if not exists stutest(
id int,name string,age int,sex string
)row format delimited
fields terminated by "\t"
location '/input/stutest';
导入数据方法二:
hadoop fs -put students /input/stutest/
create table student
as
select * from stus;
分区表:
单分区:
create table if not exists stutest(
id int,name string,age int,sex string
)partitioned by (grade string)
row format delimited
fields terminated by "\t";
load data local inpath '/home/tg/datas/students' overwrite into table stutest partition (grade='g1');
双分区:
create table if not exists stutest2(
id int,name string,age int,sex string
)partitioned by (grade string,class string)
row format delimited
fields terminated by "\t";
load data local inpath '/home/tg/datas/students' overwrite into table stutest2 partition (grade='g1',class='c1');
alter table stutest2 drop partition (grade='g1',class='c1');
Join查询;
inner join
outer join:left right full
内部表:
create table if not exists student(
id int,name string,age int,sex string
)row format delimited
fields terminated by "\t";
查看创建表的信息
show create table student;
查看表结构(列)信息
desc student;
导入数据方法一:
load data local inpath '/home/tg/datas/students' overwrite into table student;
外部表:
create external table if not exists stutest(
id int,name string,age int,sex string
)row format delimited
fields terminated by "\t"
location '/input/stutest';
导入数据方法二:
hadoop fs -put students /input/stutest/
create table student
as
select * from stus;
分区表:
单分区:
create table if not exists stutest(
id int,name string,age int,sex string
)partitioned by (grade string)
row format delimited
fields terminated by "\t";
load data local inpath '/home/tg/datas/students' overwrite into table stutest partition (grade='g1');
双分区:
create table if not exists stutest2(
id int,name string,age int,sex string
)partitioned by (grade string,class string)
row format delimited
fields terminated by "\t";
load data local inpath '/home/tg/datas/students' overwrite into table stutest2 partition (grade='g1',class='c1');
alter table stutest2 drop partition (grade='g1',class='c1');
Join查询;
inner join
outer join:left right full
阅读全文
0 0
- Hive基本操作(三)
- Hive基本操作(三)
- Hive(三)--基本操作
- Hive笔记三:基本操作
- Hive体系结构(三)元数据库与基本操作
- Hive总结(二)hive基本操作
- Hive总结(二)hive基本操作
- Hive总结(二)hive基本操作
- Hive总结(二)hive基本操作
- Hive总结(二)hive基本操作
- Hive总结(二)hive基本操作
- Hive基本操作(一)
- Hive基本操作(一)
- Hive基本操作(二)
- hive的基本操作(重点)
- hive 基本操作
- hive 基本操作
- hive 基本命令操作
- 关于锐捷交换机配置
- 域名
- Python3之attr系列
- MATLAB对数据的操作
- USACO-Section2.1 Hamming Codes
- Hive基本操作(三)
- dao.duplicatekeyException
- codeforces-305A Strange Addition(思维+模拟)
- jni中使用ffmpeg
- 1、Spring框架-IoC与DI
- TQ E9开发板的二次开发
- poj1637 Sightseeing tour
- 第一次接触oracle
- 开始写博客