greenplum导入导出
简介
一、数据导入
greenplum数据导入有五种方式:
1、 insert:通过sql直接插入数据
2.、copy:通过master节点加载,无法实现并行高效数据加载
copy tablename from ‘/home/…/test.cvs’ with delimiter ‘,’;
3.、外部表:
创建外部表,然后插入数据
4.、gpload:外部表的封装
通过编辑gpload控制文件test.yml完成导入
gpload -f test.yml
5.、可执行外部表:不需要启动gpfdist服务
create external web table test1(…)
execute ‘cat /home/…/test.dat’ on master
format ‘text’ (delimiter ‘,’ null as ‘’ escape ‘off’)
encoding ‘’;
insert into test select * from test1;
二、数据导出:
1、copy命令导出
2、可写外部表导出数据:
create writable external table test1
(like test)
location (‘gpfdist://localhost:8888/test.dat’)
format ‘text’ (delimiter ‘,’)
distribute by …;
insert into test1 select * from test;
3、通过 pg_dump导出
pg_dump -f basicmod.sql -h hostname -U username -s -n schema_name db_name # -s 代表只导出schema元信息,不包括数据
4、通过psql进行数据库导出 –
psql “host=XX.XX.XX.XX port=5432 user=XXX password=XXX dbname=XXX” -f table_name.sql
使用copy导出
1、使用navicat工具
1)选择所要导出库,右键点击选择“命令列界面”
2)步骤如下:
db_name=# show server_encoding;
server_encoding
-----------------
UTF8
(1 row)
SHOW
db_name=