(二)hive 表操作

16 篇文章 0 订阅

创建表

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;

问题全部解决

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值