【GBase 8a MPP数据库集群】指定导出的文件个数和导出的文件大小

指定导出的文件个数

在 SELECT INTO OUTFILE 语句中可以指定 FILECOUNT 参数指定并行导出的文件个数,文件命名方式为 file_title+suffix+file_ext 形式,其中 file_title 是 file_name中’ .’之前的部分, file_ext 为 file_name 中’ .’之后的部分(包含’ .’) suffix为自动追加的文件名后缀,第一个文件名后缀是“ _1” ,以此类推。

示例

指定导出的文件个数 FILECOUNT(本地导出时本参数不起作用)。
示例中用到的表及部分数据:

DROP TABLE IF EXISTS test;
CREATE TABLE test (ps_partkey bigint,ps_suppkey bigint,ps_availqty
bigint,ps_supplycost decimal(15,2),ps_comment varchar(200));

表中部分数据:

gbase>select * from test;
+------+------+------+--------+-------------------------------------+
| a | b | c | d | e |
+------+------+------+--------+-------------------------------------
| 1 | 2 | 3325 | 771.64 | , even theodolites. regular |
| 1 | 2502 | 8076 | 993.49 | ven ideas. quickly |
| 1 | 5002 | 3956 | 337.09 | after the fluffily ironic |
| 1 | 7502 | 4069 | 357.84 | al, regular dependencies |
| 2 | 3 | 8895 | 378.49 | nic accounts. final accounts |
| 2 | 2503 | 4969 | 915.27 | ptotes. quickly pending |
| 2 | 5003 | 8539 | 438.37 | blithely bold ideas. furiously |
| 2 | 7503 | 3025 | 306.39 | olites. deposits wake carefully |
| 3 | 4 | 4651 | 920.92 | ilent foxes affix furiously quickly |
| 3 | 2504 | 4093 | 498.13 | ending dependencies haggle fluffily |
| 3 | 5004 | 3917 | 645.40 | of the blithely regular theodolites |
| 3 | 7504 | 9942 | 191.92 | unusual, ironic foxes according |
| 4 | 5 | 1339 | 113.97 | carefully unusual ideas. packages |
| 4 | 2505 | 6377 | 591.18 | ly final courts haggle |
| 4 | 5005 | 2694 | 51.37 | g, regular deposits: quick |
+------+------+------+--------+-------------------------------------
800000 rows in set

导出:

gbase> SELECT * FROM test INTO OUTFILE
'HDP://192.168.153.21:50070/export/test.txt?user=gbase' OUTFILEMODE BY HDFS
FILECOUNT 3;
Query OK, 800000 rows affected

查看导出文件:

$ bin/hdfs dfs –ls /export
test_1.txt
test_2.txt
test_3.txt

指定导出文件大小

在 SELECT INTO OUTFILE 中可指定 FILESIZE 参数指定导出文件的最大大小,如 果 文 件 大 小 大 于 此 参 数 时 , 则 分 裂 产 生 新 文 件 。 新 文 件 命 名 方 式 为file_title+suffix+file_ext 形式,其中 file_title 是file_name 中’ .’之前的部分, file_ext为 file_name 中’ .’之后的部分(包含’ .’) suffix 为自动追加的文件名后缀,第一个文件名后缀是“ _p1” ,以此类推。

示例

指定导出文件大小 FILESIZE。
示例中用到的表及部分数据:

DROP TABLE IF EXISTS test;
CREATE TABLE test (ps_partkey bigint,ps_suppkey bigint,ps_availqty
bigint,ps_supplycost decimal(15,2),ps_comment varchar(200));

表中部分数据:

gbase> select * from test;
+------+------+------+--------+-------------------------------------+
| a | b | c | d | e |
+------+------+------+--------+-------------------------------------
| 1 | 2 | 3325 | 771.64 | , even theodolites. regular |
| 1 | 2502 | 8076 | 993.49 | ven ideas. quickly |
| 1 | 5002 | 3956 | 337.09 | after the fluffily ironic |
| 1 | 7502 | 4069 | 357.84 | al, regular dependencies |
| 2 | 3 | 8895 | 378.49 | nic accounts. final accounts |
| 2 | 2503 | 4969 | 915.27 | ptotes. quickly pending |
| 2 | 5003 | 8539 | 438.37 | blithely bold ideas. furiously |
| 2 | 7503 | 3025 | 306.39 | olites. deposits wake carefully |
| 3 | 4 | 4651 | 920.92 | ilent foxes affix furiously quickly |
| 3 | 2504 | 4093 | 498.13 | ending dependencies haggle fluffily |
| 3 | 5004 | 3917 | 645.40 | of the blithely regular theodolites |
| 3 | 7504 | 9942 | 191.92 | unusual, ironic foxes according |
| 4 | 5 | 1339 | 113.97 | carefully unusual ideas. packages |
| 4 | 2505 | 6377 | 591.18 | ly final courts haggle |
| 4 | 5005 | 2694 | 51.37 | g, regular deposits: quick |
+------+------+------+--------+-------------------------------------
800000 rows in set

导出:

gbase> SELECT * FROM test INTO OUTFILE '/home/gbase/temp/test.txt' FILESIZE 33554432;
Query OK, 800000 rows affected

查看导出文件:

$ ll
test_p1.txt
test_p2.txt
test_p3.txt
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值