一、 库:
同mysql中的数据库
将数据进行细化管理 不同业务模块的数据放在一个数据库中
分库 分表
hive中不同的模块的数据一般放在不同的数据库中
便于数据管理
二、 表:
hive数据的管理权限分:
内部表:
管理权限是hive自己, hive对表中的数据(原始数据)有绝对的增删权限。内部表在进行删除表时,表中的数据(hdfs对应的目录)会被删除(元数据被删除)
例:创建
create table if not exists stu_managed(sid int,name string,sex string,age int,dept string) comment “test one managed_table” row format delimited fields terminated by “,”;
外部表:
外部表更像一个hdfs的数据使用者,使用的数据管理权限hdfs自己管理,对hive来说只有使用权限。外部表在删除时,元数据会被删除,表中的数据(hdfs)hdfs对应的数据不会被删除
例:创建
create external table if not exists stu_external(sid int,name string,sex string,age int,dept string) comment “test one external_table” row format delimited fields terminated by “,