欢迎投稿

今日深度:

Hive学习笔记(7),

Hive学习笔记(7),


1 Hive 表的类型

1.1 默认都是 管理表(内部表)

  • 内部表删除表时,会删除表数据和元数据;
  • 默认存在 /user/hive/warehouse,可以通过 location 指定

desc formatted dept;

1.2 创建外部表

  • 删除表时,只会删除元数据,不会删除表数据(在 HDFS);
  • 创建表时可以自己指定目录位置
  • 企业大部分用的外部表
create external table if not exists default.emp_ext(
empno int,
ename string,
job string,
mgr int,
hiredate string,
sal double,
comm double,
deptno int
) row format delimited fields terminated by '\t';

desc formatted emp_ext;

1.2.1 创建外部表并且指定位置

将数据和表放到 HDFS 用一个目录,数据会自动导入

  • hive (default)> dfs -mkdir -p /user/hive/warehouse/emp_ext2;
  • `hive (default)> dfs -put /home/hadoop/emp.txt /user/hive/warehouse/emp_ext2;
create external table if not exists default.emp_ext2(
empno int,
ename string,
job string,
mgr int,
hiredate string,
sal double,
comm double,
deptno int
) row format delimited fields terminated by '\t'
location '/user/hive/warehouse/emp_ext2';

www.htsjk.Com true http://www.htsjk.com/hive/32878.html NewsArticle Hive学习笔记(7), 1 Hive 表的类型 1.1 默认都是 管理表(内部表) 内部表删除表时,会删除表数据和元数据; 默认存在 /user/hive/warehouse ,可以通过 location 指定 desc formatted dept; 1.2 创建外部...
相关文章
    暂无相关文章
评论暂时关闭