创建表
CREAT TABLE table_name
[(col_nem date_type [COMMENT col_comment])]
creat table hive_wordcount(context string)
在mysql中:
select* fromTBLS
select*fromCOLUMNS_V2
加载数据到hive表
LOAD DATA LOCAL INPATH 'filepath' INTO TABLE tablename
load date local inpath '/home/hadoop/date/hello/txt' into table hive_wordcount
select word ,count(1) from hive_wordcount lateral view explode(split(context,'\t')) wc as word group by word
lateral view explode():是吧每行记录按照指定分隔符进行拆解
hive ql 提交执行以后会生成MapReduce作业,并在yarn上运行
小案例:
在hive中执行建表语句:
一、员工表create table emp(empno int,ename string,job string,mgr int,hiredate string,sal double,comm double,deptno int)row format delimited fields terminated by '\t';二、部门表create table dept(deptno int,dname string,loc string)row format delimited fields terminated by '\t';
加载数据
load data