zoukankan      html  css  js  c++  java
  • [hive] hive 内部表和外部表

    1.内部表

    hive (test1)> create table com_inner_person(id int,name string,age int,ctime timestamp) row format delimited fields terminated by ',';
    OK
    Time taken: 0.233 seconds
    hive (test1)> load data local inpath '/opt/hadoop/person.data' into table com_inner_person;
    Loading data to table test1.com_inner_person
    Table test1.com_inner_person stats: [numFiles=1, totalSize=142]
    OK
    Time taken: 0.602 seconds
    hive (test1)> select * from com_inner_person;
    OK
    1       王思琪  12      NULL
    2       张三    13      NULL
    3       王丽    43      NULL
    4       三四    23      NULL
    5       Python  12      NULL
    Time taken: 0.075 seconds, Fetched: 5 row(s)

    删除表后,数据也一起删除。 

    2.外部表

    hive (test1)> create external table com_ext_person (id int,name string,age int,ctime timestamp) row format delimited fields terminated by ',' location '/opt/hadoop/external';
    OK
    Time taken: 0.205 seconds
    hive (test1)> load data local inpath '/opt/hadoop/person.data' into table com_ext_person;
    Loading data to table test1.com_ext_person
    Table test1.com_ext_person stats: [numFiles=0, totalSize=0]
    OK
    Time taken: 0.512 seconds
    hive (test1)> select * from com_ext_person;
    OK
    1       王思琪  12      NULL
    2       张三    13      NULL
    3       王丽    43      NULL
    4       三四    23      NULL
    5       Python  12      NULL
    6       spark   32      NULL
    Time taken: 0.086 seconds, Fetched: 6 row(s)

     在指定的location中查看hdfs数据

    删除表后,数据仍在。

     

  • 相关阅读:
    Docker之路-docker架构
    Docker之路-认识docker
    Docker之路-版本选择及安装
    Golang理解-集合
    大话算法-动态规划算法
    运维职责
    Golang理解-匿名结构体
    DotNetty项目基本了解和介绍
    变量声明在循环体内还是循环体外的争论
    SqlServer与MySql语法比较
  • 原文地址:https://www.cnblogs.com/lonelywolfmoutain/p/6929830.html
Copyright © 2011-2022 走看看