Hive_Hive的数据模型_外部表
2024-09-01 04:25:58
Hive的数据模型之外部表
外部表(External Table)
- 指向已经在HDFS中存在的数据,可以创建Partition
- 它和内部表在元数据的组织上是相同的,而实际数据的存储则有较大的差异。
- 外部表侄有一个过程,加载数据和创建表同时完成,并不会移动到数据仓库目录中,只是与外部数据建立一个链接。当删除一个外部表时,仅删除该链接。
1、准备几张相同数据结构的数据txt文件,放在HDFS的/input 目录下。
2、在hive下创建一张有相同数据结构的外部表external_student,location设置为HDFS的/input 目录。则external_student会自动关连/input 下的文件。
3、查询外部表。显示/input下具有相同数据结构的所有文件的数据。
4、删除/input目录下的部分文件。
5、查询外部表。删除的那部分文件数据不存在。
6、将删除的文件放入/input目录。
7、查询外部表。放入的那部分文件数据重现。
举例如下:
(1)准备数据:
student1.txt
1,Tom,M,60,80,96
2,Mary,F,11,22,33 student2.txt
3,Jerry,M,90,11,23 student3.txt
4,Rose,M,78,77,76
5,Mike,F,99,98,98
查看HDFS文件系统现有的目录。
# hdfs dfs -ls / 创建input目录。
# hdfs dfs -mkdir /input
将文件放入HDFS文件系统
hdfs dfs -put localFileName hdfsFileDir
# hdfs dfs -put student1.txt /input
# hdfs dfs -put student2.txt /input
# hdfs dfs -put student3.txt /input
(2)创建外部表
create table external_student
(sid int, sname string, gender string, language int, math int, english int)
row format delimited fields terminated by ','
location '/input';
(3)查询外部表
select * from external_student;
(4)删除HDFS上的student1.txt
# hdfs dfs -rm /input/student1.txt
(5)查询外部表
select * from external_student;
(6)将student1.txt 重新放入HDFS input目录下
# hdfs dfs -put student1.txt /input
(7)查询外部表
select * from external_student;
最新文章
- C#中Dictionary<;TKey,TValue>;排序方式
- webservice入门(2)开发ws程序
- 转:用WCAT进行IIS压力测试
- COALESCE NVL NVL2 DECODE
- linux下php-fpm 启动参数及重要配置
- JVM系列三:JVM参数设置、分析
- C++学习14 继承的概念及语法
- Codeforces Round #260 (Div. 1) C. Civilization 并查集,直径
- Hive over HBase和Hive over HDFS性能比较分析
- Java Web SSH框架总是无法写入无法读取Cookie
- 对于方法 String.Contains,只支持可在客户端上求值的参数。
- 有关SetTimer函数的用法
- JavaWeb核心编程之Tomcat安装和配置
- linux yum命令
- hdu 1251 统计拼图
- [读书心得] .NET中 类型,对象,线程栈,托管堆在运行时的关系
- 详解equals()方法和hashCode()方法
- 在myeclipse的jsp编辑器中怎么把Source/Preview调出来的方法步骤
- phpexcel用法(转)
- 【linux】awk相关