Hive基本使用——命令行 - 白石江边 - 博客园


本站和网页 https://www.cnblogs.com/zwcoding/p/9269712.html 的作者无关,不对其内容负责。快照谨为网络故障时之索引,不代表被搜索网站的即时页面。

Hive基本使用——命令行 - 白石江边 - 博客园
首页
新闻
博问
专区
闪存
班级
我的博客
我的园子
账号设置
简洁模式 ...
退出登录
注册
登录
白石江边
博客园
首页
新随笔
联系
订阅
管理
Hive基本使用——命令行
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;OKdefaultzwctestTime taken: 0.019 seconds, Fetched: 2 row(s)
切换数据库
切换数据库的时候可以输入:use database_name;
hive> use zwctest;OKTime 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;OKTime taken: 0.163 seconds
查看所有表
hive> show tables;OKtesttableTime taken: 0.023 seconds, Fetched: 1 row(s)
查看表信息
hive> desc studenttable;OKname 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;OKTime taken: 0.198 seconds
表加载数据
hive> load data local inpath '/data/apps/test/zhangwenchao/data/data.txt' into table studenttable; Loading data to table zwctest.studenttableTable zwctest.studenttable: [numFiles=1, totalSize=2117]OKTime taken: 0.659 seconds
查看数据
select * from testtable;
posted @
2018-07-05 17:51
白石江边
阅读(19985)
评论(0)
编辑
收藏
举报
刷新评论刷新页面返回顶部
Copyright 2022 白石江边
Powered by .NET 7.0 on Kubernetes