hive
hive是什么?
基于hadoop的数据仓库
通过类sql语句转换成MapReduce执行
数据库与数据仓库的区别
DDL
关于数据库和表结构的操作
create drop alter show
DML
关于表内数据的操作
insert select
几种数据的导入导出方式
1.insert into table values(...)
2.load data [local] inpath "" [overwrite] into table tbName
3.insert into/overwrite table tbName select * from tbName1
4.create table tbName location "...."
5.create table tbName as select * from tbName1
6.create table tbName like tbName1
7.load overwrite local directory "..." select * from tbName;
内部表和外部表
-
内部表 MANAGE_TABLE
表结构(元数据)和真实数据同时删除,不安全 -
外部表 EXTERNAL_TABLE
表结构(元数据)删除,但是真实数据保留,
可以通过创建同名表的形式恢复数据,比较安全
建表语句
create [external] table tbName (field type,…)
row format delimited
fields terminated by “\t”
分区
相当于sql语句中的where条件。