hive建表

1.查看数据库
show databases

2.创建数据库
create database test
create database test location ‘hdfs://test/test.db/’

3.删除数据库
drop database test //如果有表则不能删除
drop database test cascade //强制删除数据库

4.进入数据库
use test

5.查看表
show tables

6.创建表
create [external] table ylq (
id int,
name string comment ‘姓名’,
age int comment ‘年龄’
) partitioned (day string)
row format delimited
fields terminated by ‘|’
stored as textfile
location ‘hdfs://test/test.db./ylq’

关键字
external 创建外部表,删除表,不会删除表数据(表数据在hdfs上)

comment 注释

partitioned by 创建表分区

row format delimited 指定数据格式
fields terminated by ‘|’ //指定每行中字段分隔符为竖线
lines terminated by ‘\n’ //指定行分隔符
collection items terminated by ‘,’ //指定集合中元素之间的分隔符
map keys terminated by ‘:’ //指定数据中Map类型的Key与Value之间的分隔符

stored as hdfs上表存储数据的格式
textfile //文本
sequencefile // 二进制序列文件
rcfile //列式存储格式文件 Hive0.6以后开始支持
orc //列式存储格式文件,比RCFILE有更高的压缩比和读写效率,Hive0.11以后开始支持
parquet //列出存储格式文件,Hive0.13以后开始支持

location 指定文件在hdfs路径

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值