drop database if exists test cascade;
cascade关键字:删除库下的所有表
(14)内部表
(1)内部表的表数据都在其内部,hdfs上的/usr/hive/warehouse/库名/表名中
建内部表:指定文件格式和分割符
create table if not exists student(id int,name string)
row formated delimited fields terminated by ','
stored as textfile;
导入数据:
将文件导入到表:student的目录下
删除表student的同时会删除该目录下的数据文件
(15)外部表
(2)外部表的元数据存在mysql上的hive库中,表数据存放在hdfs上
建外部表:
create external table if not exists ext_student(id int,name string)
row format delimited fields terminated by ','
stored as textfile
location '/text'
(16)导入数据
load data [local] inpath '文件路径'
[overwrite] into table 表名
local:
有是代表虚拟机路径,没有就是hdfs路径
overwrite:
有是代表覆盖,没有就是追加