Hive的數據類型

hive的基本數據類型java

  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<string>,
      > deductions map<string,float>,
      > address struct<street:string,city:string,state:string,zip:int>
      > );數組

hive的數據編碼格式oop

  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;spa

hive的讀時模式orm

  1.傳統的關係型數據庫在進行數據加載時,必須驗證數據格式是否符合表字段定義,若是不符合,數據將沒法插入至數據庫表中。這種模式稱爲「寫時模式」。對象

  2.hive中,數據加載過程採用「讀時模式」。ip

hive數據存在什麼地方hadoop

  1.數據將存儲在hdfs中,在{/user/hive/warehouse/}目錄的*_db下面。

  刪除表中的所有數據,你將執行$>hadoop fs -rm /user/hive/warehouse/employees/employees.txt

相關文章
相關標籤/搜索