一、数据导入
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元信息,不包括数据