指定导出的文件个数
在 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