Hive基本使用——命令行
来源:互联网 发布:php自动跳转页面 编辑:程序博客网 时间:2024/06/05 04:15
Hive 用户接口主要有三个:命令行(CLI),客户端(Client) 和 Web界面(WUI)。其中最常用的是 CLI,启动的时候,会同时启动一个 Hive 服务。Client 是 Hive 的客户端,用户连接至 Hive Server。在启动 Client 模式的时候,需要指出 Hive Server 所在节点,并且在该节点启动 Hive Server。 WUI 是通过浏览器访问 Hive的Web工具
这里介绍Hive命令行的一个基本使用
注意
hive命令行语句后面一定要加分号
创建数据库
hive> create database zwctest;
查看数据库
hive> show databases;
OK
default
zwctest
Time taken: 0.019 seconds, Fetched: 2 row(s)
切换数据库
切换数据库的时候可以输入:use database_name;
hive> use zwctest;
OK
Time taken: 0.012 seconds
删除数据库
hive> drop database if exists zwctest;
创建表
创建一个外部表,表有字段name,sex,age。comment后面内容为字段描述信息。
hive> create external table if not exists studenttable(
> name string comment 'name value',
> sex string comment 'sex value',
> age string comment 'age value')
> row format delimited
> fields terminated by '\t'
> lines terminated by '\n'
> stored as textfile;
OK
Time taken: 0.163 seconds
查看所有表
hive> show tables;
OK
testtable
Time taken: 0.023 seconds, Fetched: 1 row(s)
查看表信息
hive> desc studenttable;
OK
name string name value
sex string sex value
age string age value
#这里面有一个字段data,是string类型的,描述信息comment是“d comment”。
查看拓展描述信息
hive> describe formatted studenttable;
OK
# col_name data_type comment
name string name value
sex string sex value
age string age value
# Detailed Table Information
Database: zwctest
Owner: root
CreateTime: Sun Oct 23 17:52:38 CST 2016
LastAccessTime: UNKNOWN
Protect Mode: None
Retention: 0
Location: hdfs://test1:8020/user/hive/warehouse/zwctest.db/studenttable
Table Type: EXTERNAL_TABLE
Table Parameters:
EXTERNAL TRUE
transient_lastDdlTime 1477216358
# 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:
field.delim \t
line.delim \n
serialization.format \t
Time taken: 0.055 seconds, Fetched: 31 row(s)
注:desc为简写,可写全拼describe
删除表
hive> drop table testtable;
OK
Time taken: 0.198 seconds
表加载数据
hive> load data local inpath '/data/apps/test/zhangwenchao/data/data.txt' into tablestudenttable;
Loading data to table zwctest.studenttable
Table zwctest.studenttable: [numFiles=1, totalSize=2117]
OK
Time taken: 0.659 seconds
查看数据
select * from testtable;
- Hive基本使用——命令行
- 使用Hadoop和Hive命令行
- Hive基本使用①
- Hive基本使用
- Hive 基本使用
- HIVE基本语法使用
- Hive的基本使用
- Hive 的基本使用
- hive的基本使用
- Hive基本使用
- Hive-命令行基本操作和java API访问hive数据库
- Hive Shell 基本操作——深入浅出学Hive
- (8)Hive Shell 基本操作——深入浅出学Hive
- Hive Shell 基本操作——深入浅出学Hive
- 深入浅出学Hive——Hive Shell基本操作
- hive的基本使用01
- hive的基本使用02
- [一起学Hive]之八-使用Hive命令行
- java中的匿名内部类总结
- UNIX新手-常用命令笔记
- 为镜像img改密码
- hdu2586 How far away? Tarjan(离线)算法求最近公共祖先LCA 待补完
- PAT测试1001 害死人不偿命的(3n+1)猜想 java实现
- Hive基本使用——命令行
- Ubuntu-server 下Apache2 配置.htaccess 隐藏thinkPHP项目index.php
- 易语言使用LhSocket5Net创建Socket5服务器
- 学习笔记
- 106. Construct Binary Tree from Inorder and Postorder Traversal
- 百度笔试--计算机视觉算法工程师
- 279. Perfect Squares
- (新规)最高法、最高检、公安部《关于电子数据收集提取判断的规定》(2016年10月1日施行)
- Android Studio鼠标悬停显示注释