DML:Data Manipulation Language 数据操纵语言
1、插入数据到数据表
1、建表后插入数据
a)语法:
LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename
[PARTITION (partcol1=val1, partcol2=val2 ...)]
b)注意:
不加local剪切hdfs上的数据到hive数据目录,加local复制linux本地的数据到hive数据目录
c)示例:
creat table emp (id int,name string) row format delimited
fields terminated by '\t' lines terminated by '\n';
load data [local] inpath '/user/hive/warehouse/test1.db/test' into table emp;
导入hdfs数据是剪切,导入本地Linux数据是复制。
d)非DML方式:
第1种方式:
creat table emp (id int,name string)row format delimited
fields terminated by '\t' lines terminated by '\n';
location hdfs_path;
hdfs dfs -put /tmp/emp /user/hive/warehouse/test1.db/test;
第2种方式:
creat table emp (id int,nam