建表语句
hive
(default)> create table
dept_partition(
deptno
int, dname string
, loc string
)
partitioned by
(month string
)
row format delimited fields terminated by
'\t';
shell 脚本
#!/bin/bash
action
="";
for file in /opt/module/datas/AccountCharge/*
do
name
=${file//.txt/ };
str
=$(echo $name | awk -F '/' '{print $NF}')
action
=$action'load data local inpath "'$file'" into table dept_partition
partition(month="'$str'")'';'
done
hive -e
"$action"