0004.熟悉hive创建mysql数据库中的表关系
来源:互联网 发布:p2p网络借款平台 编辑:程序博客网 时间:2024/06/05 15:04
1.创建数据库名为hive
2.数据库中表的个数默认为29个表。
3.创建一个表people
hive> create table people (id int, name string);
4.解释执行上面语句的数据都放在那些表中
(1)TBLS(tables)所有创建的表都在这个表中。
(2)COLUMNS_V2创建表的字段
(3)表与字段直接关系通过主外键进行关联。
(4)SDS表对应表的hdfs目录
默认数据存放的位置
在hdfs://hadoop12:9000/user/hive/warehouse/people
这个目录下查找数据。
mysql中保存的是表的描述信息。
5.通过命令行查看表结构
(1)查看表信息:能够查看表的字段:
desc people;
(2)查看表结构详细信息(比较乱):desc extended people;
(3)查看表结构详细信息(格式化):desc formatted people;
hive> desc people;
OK
id int
name string
Time taken: 0.84 seconds, Fetched: 2 row(s)
hive> desc extended people;
OK
id int
name string
Detailed Table Information Table(tableName:people, dbName:default, owner:root, createTime:1448672961, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:id, type:int, comment:null), FieldSchema(name:name, type:string, comment:null)], location:hdfs://hadoop:9000/user/hive/warehouse/people, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format=1}), bucketCols:[], sortCols:[], parameters:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[], skewedColValueLocationMaps:{}), storedAsSubDirectories:false), partitionKeys:[], parameters:{transient_lastDdlTime=1448672961}, viewOriginalText:null, viewExpandedText:null, tableType:MANAGED_TABLE)
Time taken: 0.105 seconds, Fetched: 4 row(s)
hive> desc formatted people;
OK
# col_name data_type comment
id int
name string
# Detailed Table Information
Database: default
Owner: root
CreateTime: Fri Nov 27 17:09:21 PST 2015
LastAccessTime: UNKNOWN
Protect Mode: None
Retention: 0
Location: hdfs://hadoop:9000/user/hive/warehouse/people
Table Type: MANAGED_TABLE
Table Parameters:
transient_lastDdlTime 1448672961
# Storage Information
SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
InputFormat: org.apache.hadoop.mapred.TextInputFormat
OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
Compressed: No
Num Buckets: -1
Bucket Columns: []
Sort Columns: []
Storage Desc Params:
serialization.format 1
Time taken: 0.151 seconds, Fetched: 27 row(s)
OK
id int
name string
Time taken: 0.84 seconds, Fetched: 2 row(s)
hive> desc extended people;
OK
id int
name string
Detailed Table Information Table(tableName:people, dbName:default, owner:root, createTime:1448672961, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:id, type:int, comment:null), FieldSchema(name:name, type:string, comment:null)], location:hdfs://hadoop:9000/user/hive/warehouse/people, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format=1}), bucketCols:[], sortCols:[], parameters:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[], skewedColValueLocationMaps:{}), storedAsSubDirectories:false), partitionKeys:[], parameters:{transient_lastDdlTime=1448672961}, viewOriginalText:null, viewExpandedText:null, tableType:MANAGED_TABLE)
Time taken: 0.105 seconds, Fetched: 4 row(s)
hive> desc formatted people;
OK
# col_name data_type comment
id int
name string
# Detailed Table Information
Database: default
Owner: root
CreateTime: Fri Nov 27 17:09:21 PST 2015
LastAccessTime: UNKNOWN
Protect Mode: None
Retention: 0
Location: hdfs://hadoop:9000/user/hive/warehouse/people
Table Type: MANAGED_TABLE
Table Parameters:
transient_lastDdlTime 1448672961
# Storage Information
SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
InputFormat: org.apache.hadoop.mapred.TextInputFormat
OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
Compressed: No
Num Buckets: -1
Bucket Columns: []
Sort Columns: []
Storage Desc Params:
serialization.format 1
Time taken: 0.151 seconds, Fetched: 27 row(s)
hive>
解释描述信息
Location: 数据存放位置
Table Type: MANAGED_TABLE //内部表
SerDe Library: 序列化方法
InputFormat: 输入格式
OutputFormat: 输出格式
Compressed: 是否压缩
Num Buckets: 分桶个数
Bucket Columns: ??不明白
0 0
- 0004.熟悉hive创建mysql数据库中的表关系
- 通过学生-课程关系表,熟悉hive语句
- 通过学生-课程关系表,熟悉hive语句
- 通过学生-课程关系表,熟悉hive语句
- Hive数据库创建、表创建、加载数据
- hive Sortby/Order by/Cluster By/Distribute By 操作 通过学生-课程关系表熟悉hive语句
- hive 中的 关系运算
- hive 中的 关系运算
- MySQL中的实例、数据库关系简介
- MySQL中的实例、数据库关系简介
- mysql:众多关系型数据库中的一种
- hive数据库与表的创建
- hive创建数据库
- Hive 创建数据库异常
- Hive创建、删除数据库
- mysql 创建数据库,创建表
- mysql 创建数据库创建表
- MySQL 创建数据库 创建表
- 堆栈的生长方向
- 阿里云服务器linux安装vnc过程
- 读书笔记-Android开发艺术探索-第3章-View的事件体系
- CentOS 7 编译安装httpd-2.4.17
- winsocket笔记01
- 0004.熟悉hive创建mysql数据库中的表关系
- 博客迁移到 http://blog.ykgzs.com
- Qt 打开保存文件对话框
- Spring/Hibernate 应用性能优化的7种方法
- 第六届蓝桥杯大赛个人赛(软件类)校内选拔题目\Java大学B组\1题
- VMware创建Linux虚拟机,安装CentOS7
- pip 碰到字符集的问题解决
- python默认编码与解码格式设置
- 2015广东工业大学新生赛决赛 Problem I: Stubird说这是水题