hive的基本数据类型

hive的基本数据类型

1.基本数据类型

hive类型        说明         java类型      实例
  1).tinyint      1byte有符号的整数    byte        20
  2).smalint     2byte有符号的整数   short       20
  3).int       4byte有符号的整数   int        20
  4).bigint      8byte有符号的整数   long       20
  5).boolean     布尔类型true或false   boolean     true
  6).float      单精度         float 3.217
  7).double    双精度         double 3.212
  8).string      字符序列,单双即可   string ‘zhang’;“ashakjds”
  9).timestamp    时间戳,精确的纳秒 timestamp ‘158030219111’
  10).binary      字节数组        byte[]

2.集合数据类型

hive类型      说明                       java类型             实例
  1).struct        对象类型,可以通过字段名.元素名来访问      object          struct(‘name’,‘age’)
  2).map        一组键值对的元组                 map            map(‘name’,‘zhangsan’,‘age’,‘23’)
  3).array          数组                     array            array(‘name’,‘age’)
  4).union          组合
  3.案例:
    hive>create table employees(
      > name string,
      > salary float,
      > subordinates array,
      > deductions map<string,float>,
      > address structstreet:string,city:string,state:string,zip:int
      > );

hive的数据编码格式

1.默认hive通过^A(\001)、^B(\002)、^C(\003)分别对列、(array和struct)、map进行匹配;

2.创建表时,可以通过以下命令进行设置:
    row format delimited
    fields terminated by ‘\001’
    collection items terminated by ‘\002’
    map keys terminated by ‘\003’
    lines terminated by ‘\n’
  3.加载数据
    $>cd ~
    $>cp /mnt/hgfs/2.安装环境/data/employees/employees.txt .
    hive> load data local inpath ‘/home/hyxy/employees.txt’ into table employees;
    hive>select * from employees;

hive的读时模式

1.传统的关系型数据库在进行数据加载时,必须验证数据格式是否符合表字段定义,如果不符合,数据将无法插入至数据库表中。这种模式称为“写时模式”。

2.hive中,数据加载过程采用“读时模式”。

hive数据存在什么地方

1.数据将存储在hdfs中,在{/user/hive/warehouse/}目录的*_db下面。

删除表中的全部数据,你将执行$>hadoop fs -rm /user/hive/warehouse/employees/employees.txt

转载:
https://www.cnblogs.com/lyr999736/p/9468469.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值