Hive 笔记之 创建外部分区表并加载数据
第一 创建数据库并自定义路径 如 /sogou/500w
hive> create database sogou location "/sogou/500w" ;
进入改表中创建表
hive> use sogou;
第二步 创建外部分区表 如 sogou_partition
hive> create external table sogou_partition (ts string,uid string,keyword string,rank int ,order int,ulr string) partitioned by (year string,month string,day stirng,hour string) row Format delimited fields terminated by " " location "/sogou";
标准格式 (注意关键字要大写)
hive> CREATE EXTERNAL TABLE sogou_partition(ts STRING,uid STRING,keyword STRING,rank INT, order INT, url STRING) PARTITIONED BY (year STRING,month STRING,day STRING,hour STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY " " LOCATION "/sogou_3/500w";
名词解释:
row 行
format 格式化
delimited 划定界限的
fields 区域
terminated 终止第三步 加载数据
hive> load data local inpath "/home/zkpk/resource/sogou-data/500w/ sogou.500w.utf8" into table sogou_partition_3 partition (year="2011",month="12",day="30",hour="10");
第四步查询数据(前100行)
hive> select * from 搜狗_partition_3 limit 100;
- 上一篇: 使用kylin踩过的坑
- 下一篇:没有了