创建库:
create database 库名;
创建表入库:
create table 表名(
a string,
b string,
c string)
row format delimited
fields terminated by “:” --> 按什么切分
stored as textfile;
导入预处理之后的数据刀原始表中的语句
load data local inpath ‘/opt/user.txt’ into table 表名;
load data local inpath ‘/opt/part-r-00000’ ovewrite into table video_ori;
从原始表查询并插入数据
insert into table 表名 select * from 表名;
数据的分析阶段
hive -e "select * from 库.表名 where 条件 " > /路径/存放文件名.txt
创建外部表的语句
create external table 表名(
a string,
b string,
c string)
row format delimited
fields terminated by “\t” --> 按什么切分
stored as textfile;
将第三部的结果数据加载到外部表中
load data local inpath ‘/路径/存放文件名.txt’ into table 表名;
加载映射表
create table 数据库.映射表名(
videoId string,
a string,
b string,
c string)
stored by ‘org.apache.hadoop.hive.hbase.HBaseStorageHandler’ With serdeproperties(“hbase.columns.mapping”=“cf:a,cf:b,cf:c”)
tblproperties(“hbase.table.name” = “映射表名”);
插入表语句
insert into table 映射表名 select * from 表名;