概述
相关命令
odpscmd里面包含了tunnel
test11_123>tunnel help;
Usage: tunnel <subcommand> [options] [args]
Type 'tunnel help <subcommand>' for help on a specific subcommand.
Available subcommands:
upload (u)
download (d)
resume (r)
show (s)
purge (p)
help (h)
tunnel is a command for uploading data to / downloading data from ODPS.
上传
create table test(id int,name string);
create table test_p(id int,name string) partitioned by (gender string);
show tables;
准备数据
1,person1
2,person2
#数据上传,上传的方式是追加的形式写入数据,如果有中文 -c gbk,
#-dbr true如果导入数据的时候有格式错误就会跳过格式错误的语句
tunnel upload C:\Users\zhang\Desktop\test.txt test -fd ","
test11_123>select * from test;
outputs:
+------------+------------+
| id | name |
+------------+------------+
| 1 | person1 |
| 2 | person2 |
+------------+------------+
A total of 2 records fetched by instance tunnel. Max record number: 10000
#导入数据到指定分区
#方式一
alter table test_p add partition(gender='male');
tunnel upload C:\Users\zhang\Desktop\test.txt test_p/gender='male';
#方式二,自动创建分区
tunnel upload C:\Users\zhang\Desktop\test.txt test_p/gender='fmale' -acp true;
#指定分区查找
select * from test_p where gender='fmale';
test11_123>show partitions test_p;
gender=fmale
gender=male
OK
test11_123>
下载
总结
TunnelSDK
上传
下载