hive基础*:建表+导入数据+导出大文件
1.建表
fields terminated by 数据列分隔符,根据实际情况定
lines terminated by 数据行分隔符,根据实际情况定
partitioned表示分区,数据量不大、无区域数据调整的情况下,一般不用分区。不用时,直接将 PARTITIONED BY(**) 删除即可
stored as 文件格式,见《Hive文件格式(表STORE AS 的四种类型)》
location 对应一个目录
建表语句如下:
drop table if exists test_1;
create external table test_1(
activity_id string comment '活动id'
,tocc_name string comment '活动名称'
,app_key string
,page string
,visit_type string comment '访问类型'
)
PARTITIONED BY (
day string comment '天分区'
)
row format delimited fields terminated by '\t'
lines terminated by '\n'
stored as textfile
location '/user/test/acticity';
2.1导入外部数据
需要先将表文件处理好,(1)注意数据的格式,最常见的为将含中文的文件保存为utf-8格式&#