Hive的数据模型之内部表
2017-11-23 20:36
176 查看
一 内部表(Table)
1、与数据库中的Table在概念上是类似的。
2、每一个Table在Hive中都有一个相应目录存储数据。
3、所有的Table数据(不包括External Table)都保存在这个目录中。
4、删除表时,元数据与数据都会被删除。
二 实战
1、表保存在默认位置
hive> create table t1
> (tid int,tname string,age int);
OK
Time taken: 29.35 seconds
2、表保存在指定位置
hive> create table t2
> (tid int,tname string,age int)
> location '/mytable/hive/t2';
OK
Time taken: 2.767 seconds
3、指定列与列之间的分隔符
hive> create table t3
> (tid int,tname string,age int)
> row format delimited fields terminated by ',';
OK
Time taken: 0.407 seconds
4、创建表时插入数据
hive> create table t4
> as
> select * from t3;
Total jobs = 3
Launching Job 1 out of 3
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_201708270801_0002, Tracking URL = http://localhost:50030/jobdetails.jsp?jobid=job_201708270801_0002 Kill Command = /opt/hadoop-1.2.1/libexec/../bin/hadoop job -kill job_201708270801_0002
Hadoop job information for Stage-1: number of mappers: 0; number of reducers: 0
2017-08-27 09:11:43,727 Stage-1 map = 0%, reduce = 0%
Ended Job = job_201708270801_0002
Stage-4 is selected by condition resolver.
Stage-3 is filtered out by condition resolver.
Stage-5 is filtered out by condition resolver.
Moving data to: hdfs://localhost:9000/tmp/hive-root/hive_2017-08-27_09-10-52_018_5702021197564296120-1/-ext-10001
Moving data to: hdfs://localhost:9000/user/hive/warehouse/t4
Table default.t4 stats: [numFiles=0, numRows=0, totalSize=0, rawDataSize=0]
MapReduce Jobs Launched:
Job 0: HDFS Read: 0 HDFS Write: 0 SUCCESS
Total MapReduce CPU Time Spent: 0 msec
OK
Time taken: 80.347 seconds
5、创建表时候插入数据,并指定列与列之间的分隔符
hive> create table t5
> row format delimited fields terminated by ','
> as
> select * from t3;
Total jobs = 3
Launching Job 1 out of 3
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_201708270801_0003, Tracking URL = http://localhost:50030/jobdetails.jsp?jobid=job_201708270801_0003 Kill Command = /opt/hadoop-1.2.1/libexec/../bin/hadoop job -kill job_201708270801_0003
Hadoop job information for Stage-1: number of mappers: 0; number of reducers: 0
2017-08-27 09:14:35,377 Stage-1 map = 0%, reduce = 0%
2017-08-27 09:14:55,391 Stage-1 map = 100%, reduce = 100%
Ended Job = job_201708270801_0003
Stage-4 is selected by condition resolver.
Stage-3 is filtered out by condition resolver.
Stage-5 is filtered out by condition resolver.
Moving data to: hdfs://localhost:9000/tmp/hive-root/hive_2017-08-27_09-14-00_308_4771435589733065831-1/-ext-10001
Moving data to: hdfs://localhost:9000/user/hive/warehouse/t5
Table default.t5 stats: [numFiles=0, numRows=0, totalSize=0, rawDataSize=0]
MapReduce Jobs Launched:
Job 0: HDFS Read: 0 HDFS Write: 0 SUCCESS
Total MapReduce CPU Time Spent: 0 msec
OK
Time taken: 59.383 seconds
6、修改数据表的结构
hive> desc t1;
OK
tid int
tname string
age int
Time taken: 0.995 seconds, Fetched: 3 row(s)
hive> alter table t1 add columns(english int);
OK
Time taken: 0.729 seconds
hive> desc t1;
OK
tid int
tname string
age int
english int
Time taken: 0.883 seconds, Fetched: 4 row(s)
7、删除数据表
hive> drop table t1;
OK
Time taken: 6.291 seconds
1、与数据库中的Table在概念上是类似的。
2、每一个Table在Hive中都有一个相应目录存储数据。
3、所有的Table数据(不包括External Table)都保存在这个目录中。
4、删除表时,元数据与数据都会被删除。
二 实战
1、表保存在默认位置
hive> create table t1
> (tid int,tname string,age int);
OK
Time taken: 29.35 seconds
2、表保存在指定位置
hive> create table t2
> (tid int,tname string,age int)
> location '/mytable/hive/t2';
OK
Time taken: 2.767 seconds
3、指定列与列之间的分隔符
hive> create table t3
> (tid int,tname string,age int)
> row format delimited fields terminated by ',';
OK
Time taken: 0.407 seconds
4、创建表时插入数据
hive> create table t4
> as
> select * from t3;
Total jobs = 3
Launching Job 1 out of 3
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_201708270801_0002, Tracking URL = http://localhost:50030/jobdetails.jsp?jobid=job_201708270801_0002 Kill Command = /opt/hadoop-1.2.1/libexec/../bin/hadoop job -kill job_201708270801_0002
Hadoop job information for Stage-1: number of mappers: 0; number of reducers: 0
2017-08-27 09:11:43,727 Stage-1 map = 0%, reduce = 0%
Ended Job = job_201708270801_0002
Stage-4 is selected by condition resolver.
Stage-3 is filtered out by condition resolver.
Stage-5 is filtered out by condition resolver.
Moving data to: hdfs://localhost:9000/tmp/hive-root/hive_2017-08-27_09-10-52_018_5702021197564296120-1/-ext-10001
Moving data to: hdfs://localhost:9000/user/hive/warehouse/t4
Table default.t4 stats: [numFiles=0, numRows=0, totalSize=0, rawDataSize=0]
MapReduce Jobs Launched:
Job 0: HDFS Read: 0 HDFS Write: 0 SUCCESS
Total MapReduce CPU Time Spent: 0 msec
OK
Time taken: 80.347 seconds
5、创建表时候插入数据,并指定列与列之间的分隔符
hive> create table t5
> row format delimited fields terminated by ','
> as
> select * from t3;
Total jobs = 3
Launching Job 1 out of 3
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_201708270801_0003, Tracking URL = http://localhost:50030/jobdetails.jsp?jobid=job_201708270801_0003 Kill Command = /opt/hadoop-1.2.1/libexec/../bin/hadoop job -kill job_201708270801_0003
Hadoop job information for Stage-1: number of mappers: 0; number of reducers: 0
2017-08-27 09:14:35,377 Stage-1 map = 0%, reduce = 0%
2017-08-27 09:14:55,391 Stage-1 map = 100%, reduce = 100%
Ended Job = job_201708270801_0003
Stage-4 is selected by condition resolver.
Stage-3 is filtered out by condition resolver.
Stage-5 is filtered out by condition resolver.
Moving data to: hdfs://localhost:9000/tmp/hive-root/hive_2017-08-27_09-14-00_308_4771435589733065831-1/-ext-10001
Moving data to: hdfs://localhost:9000/user/hive/warehouse/t5
Table default.t5 stats: [numFiles=0, numRows=0, totalSize=0, rawDataSize=0]
MapReduce Jobs Launched:
Job 0: HDFS Read: 0 HDFS Write: 0 SUCCESS
Total MapReduce CPU Time Spent: 0 msec
OK
Time taken: 59.383 seconds
6、修改数据表的结构
hive> desc t1;
OK
tid int
tname string
age int
Time taken: 0.995 seconds, Fetched: 3 row(s)
hive> alter table t1 add columns(english int);
OK
Time taken: 0.729 seconds
hive> desc t1;
OK
tid int
tname string
age int
english int
Time taken: 0.883 seconds, Fetched: 4 row(s)
7、删除数据表
hive> drop table t1;
OK
Time taken: 6.291 seconds
相关文章推荐
- Hive学习笔记 3 Hive的数据模型:内部表、分区表、外部表、桶表、视图
- hive 数据模型
- hive的数据类型和数据模型
- Hive关于内部表外部表以及分区表数据删除总结
- hive的数据模型
- hive的数据模型
- 大数据Hadoop核心架构HDFS+MapReduce+Hbase+Hive内部机理详解
- 大数据Hadoop核心架构HDFS+MapReduce+Hbase+Hive内部机理详解
- 一起学Hive——创建内部表、外部表、分区表和分桶表及导入数据
- hive内部表与外部表的区别 与Hive数据存储
- 大数据时代的技术hive:hive的数据类型和数据模型
- HIVE入门之数据模型
- Hive应用:数据外置内部表
- 大数据时代的技术hive:hive的数据类型和数据模型
- Hive的数据存储模型
- hive 操作(三)——hive 的数据模型
- Hive的数据模型—桶表
- Thinking in BigData(八)大数据Hadoop核心架构HDFS+MapReduce+Hbase+Hive内部机理详解
- Hive的数据存储(内部表,外部表,分区表,桶表,视图)
- hive的数据类型和数据模型