创建表

创建内表

create table customer(
customerId int,
firstName string,
lastName STRING,
birstDay timestamp
) row format delimited fields terminated by ','

创建外表

CREATE EXTERNAL table salaries(
gender string,
age int ,
salary DOUBLE,
zip int
)row format delimited fields terminated by ',' LOCATION '/user/train/salaries/';

载入数据

load DATA LOCAL inpath '/root/user/customer.txt' overwrite into table customer;
load DATA LOCAL inpath '/root/user/salaries.txt' overwrite into table salaries;

查看文本数据

[root@centos172 user]# cat /root/user/customer.txt
1,f,jack,,
2,f,luccy,,
[root@centos172 user]# cat /root/user/salaries.txt
male,21,10000,1
female,22,12000,2

查看数据库数据

hive> desc customer;
OK
customerid int
firstname string
lastname string
birstday timestamp
Time taken: 0.053 seconds, Fetched: 4 row(s)
hive> desc salaries;
OK
gender string
age int
salary double
zip int
Time taken: 0.041 seconds, Fetched: 4 row(s)
hive> select * from customer;
OK
1 f jack NULL
2 f luccy NULL
Time taken: 0.067 seconds, Fetched: 2 row(s)
hive> select * from salaries;
OK
male 21 10000.0 1
female 22 12000.0 2
Time taken: 0.066 seconds, Fetched: 2 row(s)
hive>

区别

因为我hive也是刚开始了解,所以只讲一部分

1.内表主要放在hdfs中默认的hive目录。外表指定了location

2.删除内表,重新创建一个一样的内表,数据不会装载

删除外表,重新创建一个一样的外表,数据会自动的装载

删除外表的操作如下

hive> drop table salaries;
OK
Time taken: 0.092 seconds
hive> select * from salaries;
FAILED: SemanticException [Error 10001]: Line 1:14 Table not found 'salaries'
hive> show tables;
OK
customer
Time taken: 0.035 seconds, Fetched: 1 row(s)
hive> CREATE EXTERNAL table salaries(
> gender string,
> age int ,
> salary DOUBLE,
> zip int
> )row format delimited fields terminated by ',' LOCATION '/user/train/salaries/';
OK
Time taken: 0.058 seconds
hive> show tables;
OK
customer
salaries
Time taken: 0.025 seconds, Fetched: 2 row(s)
hive> select * from salaries;
OK
male 21 10000.0 1
female 22 12000.0 2
Time taken: 0.058 seconds, Fetched: 2 row(s)
hive>

区别1的:

内表的默认路径

指定外表的路径如图:

hive是什么

我当前接触到就是:

1.把hdf文件具体为table

2.用来查询,类似sql语句处理

hive内表和外表的创建、载入数据、区别的更多相关文章

  1. Hive内表和外表的区别

    本文以例子的形式介绍一下Hive内表和外表的区别.例子共有4个:不带分区的内表.带分区的内表.不带分区的外表.带分区的外表. 1 不带分区的内表 #创建表 create table innerTabl ...

  2. Hive 7、Hive 的内表、外表、分区(22)

    Hive 7.Hive 的内表.外表.分区   1.Hive的内表 Hive 的内表,就是正常创建的表,在 http://www.cnblogs.com/raphael5200/p/5208437.h ...

  3. Hive 7、Hive 的内表、外表、分区

    1.Hive的内表 Hive 的内表,就是正常创建的表,在 http://www.cnblogs.com/raphael5200/p/5208437.html 中已经提到: 2.Hive的外表 创建H ...

  4. Hive的内表和外表以及分区表

    1. 内表和外表的区别 内表和外表之间是通过关键字EXTERNAL来区分.删除表时: 内表:在删除时,既删除内表的元数据,也删除内表的数据 外表:删除时,仅仅删除外表的元数据. CREATE [EXT ...

  5. hadoop-hive的内表和外表

    --创建内表create table if not exists employee(id int comment 'empoyeeid',dateincompany string comment 'd ...

  6. ABAP工作区,内表,标题行的定义和区别

         工作区域跟变量一样,是用来保存数据的.区别是变量只能从中保存一个数据.而工作区域可以存放多个.把多个数据合在一起就成工作区域了.下面我们来看看工作区域是如何定义的吧.定义有四种方法,如下:1 ...

  7. 七十一、SAP中内表的修改,改一行数据,或一行的某个字段

    一.SAP中内表的修改,只能通过工作区来修改,代码如下 二.效果如下

  8. ABAP 动态生成内表的几种方法

    最近要写个程序,既有更新的,也有删除的,需要涉及到很多系统表,如果一个表一个表进行更新或者删除太慢了,于是就想通过创建动态内表来实现这些功能,在网上找了一些资料,经过多次尝试,终于测试成功了.网上讲述 ...

  9. ABAP 内表 详解

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

随机推荐

  1. 一文复习JSP内容

    概念: JSP 全名为 Java Server Pages, 中文名叫 java 服务器页面, 其根 本是一个简化的 Servlet 设计, 它是由 Sun Microsystems 公司 倡导. 许 ...

  2. Word2010如何从指定页设置页码

    光标定位:将光标定位于需要开始编页码的页首位置.   插入分隔符的”下一页”:选择“页面布局—>分隔符—> 下一页”插入.   插入页码:选择“插入—>页码—> 页面底端”,选 ...

  3. Python,正则表达式 - (?:)示例

    例如正则表达式a(?:b),匹配后没有包含'b'的分组 >>> string 'ab ac' >>> import re >>> string = ...

  4. python正则非贪婪模式

    上一篇python正则匹配次数大家应该也发现了,除了?其他匹配次数规则都是尽可能多的匹配 那如果只想匹配1次怎么办呢,这就是正则中非贪婪模式的概念了 原理就是利用?与其他匹配次数规则进行组合 单个匹配 ...

  5. ubuntu 下的ftp详细配置

    FTP(文件传输协议)是一个较老且最常用的标准网络协议,用于在两台计算机之间通过网络上传/下载文件.然而, FTP 最初的时候并不安全,因为它仅通过用户凭证(用户名和密码)传输数据,没有进行加密. 警 ...

  6. 概率dp poj2096

    /** dp求期望的题. 题意:一个软件有s个子系统,会产生n种bug. 某人一天发现一个bug,这个bug属于某种bug,发生在某个子系统中. 求找到所有的n种bug,且每个子系统都找到bug,这样 ...

  7. 吴裕雄 python 机器学习——多项式贝叶斯分类器MultinomialNB模型

    import numpy as np import matplotlib.pyplot as plt from sklearn import datasets,naive_bayes from skl ...

  8. Subroutine 子程序 Perl 第四章

    子程序的定义是全局的,不需要事先声明.若重复定义子程序,后面的覆盖前面的. sub marine { $n +=1; print " Hello ,sailor number $_ ! &q ...

  9. 项目中报错:Unsupported major.minor version

    在开发中或多或少都会遇到如下报错: java.lang.UnsupportedClassVersionError: com/xie/IntegerTest : Unsupported major.mi ...

  10. STM32CUBEMX使用操作记录

    1.New Project 2.选择芯片型号 3.配置相关外设 4.例如选择了GPIO_Output 5.配置时钟树 灰色框点不了,这和你上一步相关外设配置有关,鼠标靠近灰色框,系统会给出提示 6.工 ...