1. 分区表创建及数据导入
1.1 创建分区表
-- 以日期pt分区,字段用\t分隔,输入格式为txt,存储格式为orc
use db_name;
drop table if exists tablename;
CREATE TABLE IF NOT EXISTS tablename (
aid string,
gender int, --性别
age string, --年龄
num bigint,
value1 array<int>,
value2 array<string>
) partitioned by (pt string comment "YYYY-MM-DD.HH_MM")
-- NULL DEFINED as 'null'
stored as orc -- textfile
-- row format delimited fields terminated by '\t'
-- STORED AS INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat'
-- OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
;
-- 存储格式亦可指定为txt
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
注意:内部表与外部表的区别
- 外部表需要添加 external 关键字,删除外部表时,HDFS中的数据文件不会一起被删除;
- 内部表不需要 external 关键字,删除表时表数据及HDFS中的

最低0.47元/天 解锁文章
6076

被折叠的 条评论
为什么被折叠?



