栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

[HIVE]hive基础语法

[HIVE]hive基础语法

  1. 创建表结构
  • parquet
CREATE TABLE  IF NOT EXISTS 表名  (
		  字段1 STRING, 
		  字段2 INTEGER,  
		  字段3 DECIMAL(38,4),
		  字段4 BIGINT,
		  LOADDATE TIMESTAMP)
		  comment 'XXX'
		  partitioned by (dt string)
		  stored as parquet
          tblproperties('parquet.compression'='SNAPPY');--压缩
  • ORC
DROp TABLE IF EXISTS 表名;
CREATE TABLE 表名  (
		  字段1 STRING, 
		  字段2 INTEGER,  
		  LOADDATE TIMESTAMP)
		  comment 'XXX'
		  partitioned by (dt string)
		  stored as ORC;
  1. 查看表结构
desc 表名
  1. 查看建表语句
show create table 表名
  1. 查看分区
show partitions 表名
  1. 插入语句
insert into 表名1 partition(dt='20210101')
select 字段1,字段2,...,字段n from 表名2
--有分区的注意记得加上 partition(dt='20210101')

6.模糊查询表

show tables like '* 表名*‘;
--注意是用 * 不是用 %
  1. 其他语法
  • 判断字段类型:typeof(col1)
select typeof(col1)  from catelog.schema.tablename
  • 更改字段类型
alter table 表名 change column 原列名 新列名 新字段类型;

例:alter table stu change column id id string;

  • 更改分区值
alter table  表名  partition( dt='tmp') rename to partition (dt='20211116');
  • 删除分区
alter table  表名  partition(dt<>'20211116')

delete from 表名 where dt<>'20211116'
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/583894.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号