创建表
hive (test_hive)> create table test_dept(
> id string,
> name string,
> input_time string,
> pid string
> );
OK
Time taken: 0.364 seconds
hive (test_hive)> show tables;
OK
test_dept
Time taken: 0.252 seconds, Fetched: 1 row(s)
加载数据到表
hive (test_hive)> load data local inpath '/root/dept.txt' overwrite into table test_dept;;
Loading data to table test_hive.test_dept
Table test_hive.test_dept stats: [numFiles=1, numRows=0, totalSize=5570, rawDataSize=0]
OK
Time taken: 1.135 seconds
查询表
出现2个问题
原始文本
1 .分隔符问题
create table test_dept_1(
id string,
name string,
input_time string,
pid string
) row format delimited fields terminated by ',' ;
load data local inpath '/root/dept.txt' overwrite into table test_dept_1;
2.第一行列名问题
tblproperties(
"skip.header.line.count"="n", --跳过文件行首n行
"skip.footer.line.count"="n" --跳过文件行尾n行
)
create table test_dept_2(
id string,
name string,
input_time string,
pid string
) row format delimited fields terminated by ','
tblproperties("skip.header.line.count"="1");
load data local inpath '/root/dept.txt' overwrite into table test_dept_2;
问题全部解决