南大通用GBase 8a导出本地文件时多了目录,gbase_export_directory参数用处

GBase 8a数据库集群提供select into outfile方式导出数据到文件,指定本地文件时,数据库参数gbase_export_directory会自动创建同名的目录。如果想去掉,需要关闭这个参数。

参数 gbase_export_directory

默认值是1,会自动创建本地导出文件是,创建同名的目录。


gbase> show variables like '%export_directory%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| gbase_export_directory | ON    |
+------------------------+-------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select * from t1 into outfile '/home/gbase/t1.txt' fields terminated by ','  ESCAPED BY '' writemode by overwrites;
Query OK, 1 row affected (Elapsed: 00:00:00.03)

查看目录
ls -l /home/gbase/t1.txt/
total 4
-rw------- 1 gbase gbase 6 Sep  4 11:43 t1.txt

关闭参数

只创建文件,不创建目录,大部分场景都是这个情况。

如果前面已经运行了带目录的,会报错目标是一个目录,不是文件,无法覆盖写。

DETAIL: (GBA-01EX-700) Gbase general error: I/O operation on /home/gbase/t1.txt failed with error - Is a directory, File name /home/gbase/t1.txt

手工将/home/gbase/t1.txt目录删掉后再测试

gbase> set gbase_export_directory =0 ;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)

gbase> show variables like '%export_directory%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| gbase_export_directory | OFF   |
+------------------------+-------+
1 row in set (Elapsed: 00:00:00.00)
gbase> select * from t1 into outfile '/home/gbase/t1.txt' fields terminated by ','  ESCAPED BY '' writemode by overwrites;
Query OK, 1 row affected (Elapsed: 00:00:00.04)

gbase> system ls -ld /home/gbase/t1.txt
ls: cannot access /home/gbase/t1.txt/: Not a directory
gbase> system ls -l /home/gbase/t1.txt
-rw------- 1 gbase gbase 6 Sep  4 11:46 /home/gbase/t1.txt
gbase>