hive使用

1 篇文章 0 订阅
1.hive中一次性使用命令:
	hive -e "select * from ldh_table limit 3";
	静默执行且保存一次性命令:  hive  -S -e "select * from ldh_table limit 3" 》 /temp/myfile
2.从文件中执行hive
	hive -f /path/file/myhive.sql
	在hive shell中用  source /path/file/myhive.sql
3.hive中执行shell命令
	加感叹号,以分号结尾
4.hive中执行hadoop的dfs命令
	去掉hadoop关键字,以分号结尾
5.注释  --
6.显示字段名称
	第一行加上  set hive.cli.print.header = true;
7.hive的数据类型:
	7.1 基本数据类型
	7.2 集合数据类型
		STRUCT
		MAP
		ARRAY
	7.3 分隔符
		\n:
		^A:分隔列
		^B:STRUCT、ARRAY分隔
		^C:MAP分隔
		create table ldh_table(name string,weight float) row format delimited fields terminated by ',';
8.数据定义
	8.1 数据库:
		create database human_resource;
		show databases like 'h.*';
		drop database if exists financials cascade;  --加上cascade自动删除financials中的表
		
	8.2 表
		create table if not exists t1 like t2;
		show tables 't.*';
		describe extended t1; --查看详细结构信息
		create table emp1 (name  string , salary string) partitioned by (county string,stat string);
		alter table t1 rename to emp1;--重命名
		alter table t1 change columns hms hoiers INT COMMENT 'the hours,the minutes,and secode' after severity;
9.数据操作
	装载数据:load data local inpath 'path' overwrite into table employees; 
	查询语句向表中插入数据:(overwrite和into差别:into是追加,overwrite会覆盖掉之前的内容)
		insert overwrite table employees partition (county = 'us',stat='or')
		select * from stag;


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值