hive的shell命令小结

hive服务:

hive --service metastore --help

set hive.cli.print.header; // 查看状态

set hive.cli.print.header=true;

add jar /home/resources.jar;

list jar;

delete jar /home/resources.jar

!表示后面接linux命令

比如:!pwd;

!ls;

dfs表示后面接hadoop命令

比如:dfs -ls /

quit exit都可以退出

通过set命令设的参数只是当前会话有效。


hiveQL简称HQL,是一种类似sql的查询语言,绝大多数语法和sql类似。HQL支持基本类型和复杂类型两大数据类型。基本类型包括TINYINT(1byte), SMALLINT(2byte), INT(4byte), BIGINT(8byte), FLOAT(4byte), DOUBLE(8byte), BOOLEAN(-), STRING(2G)。复杂类型包括ARRAY(一组有序数组,类型必须一致),MAP(无序键值对,键值内部字段类型必须相同,而且要求key的类型为基本数据类型),STRUCT(一组字段,类型任意)。


show命令的主要作用是查看database, table, function等组件的名称信息,也就是通过show命令我们可以知道我们的hive中有那些database;当前database中有哪些table,等等。和mysql的show命令类似。

describe命令的主要作用是获取database, table, partition的具体描述信息,包括存储位置,字段类型等信息。

explain命令的主要作用是获取hql语句的执行计划,我们可以通过分析这些执行计划来优化hql语句。


hive提供database的定义,database的主要作用是提供数据分割的作用,方便数据管理。命令有create describe drop

create database if not exists bigdater comment 'this is test bigdater database';

show databases;

set hive.cli.print.current.db=true;

describe database bigdater;

//要想显示头部信息

set hive.cli.print.header=true;

describe database bigdater;

drop database bigdater;


//创建表命令

create table customers(id int, name string, phone string) comment 'this is customers table' location '/customers';

create table customers2 like customers;//创建表,并且不将数据copy进去

create table customers3 as select * from customers;//创建表,并且将数据copy进去


create table complex_table_text(id int, name string, flag boolean, score array<int>, tech map<string, string>, other struct<phone: string, email: string>)

row format delimited fields terminated by '\;' collection items terminated by ',' map keys terminated by ':' LOCATION 'hdfs://hh:8020/complex_table_test';





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值