哥伦布

博客园 首页 新随笔 联系 订阅 管理

通过Greenplum外部表可以快速导入数据
create external table "public"."ext_tablename" ( like "public"."ext_tablename_model" ) location ( 'gpfdist://10.0.0.1:8088/desdata/upload/tablename.txt' ) format 'text' (delimiter E'\001' newline 'CRLF' escape 'off' null '\\N');
格式说明:

  • delimiter 列的分隔字符,仅可以配置一个字符,如果是不可见字符,那么需要转义,就是在前面加字母E,如:E'\001' 表示使用ASCII为0x01的不可见字符;其他如'|'表示使用|作为字段间的分隔符(ASCII码为0x7c的字符)。如果导入单列数据可以使用off表示没有列分隔符。
  • newline 不同行之间的分隔符,有3个配置类型。分别是:LF、CR、CRLF。具体功能不解释。
  • escape 转义字符的定义,可以使用当个字符;或使用off表示不转义
  • null 空值字符串表示。如果是是\则需要用\来表示。比如上例中'\N'。表示txt中,使用“\N”表示空值。

注意:“gpfdist/gpload ERROR: value too long”的处理。使用gpfdist -m max_length 参数解决问题。

原文链接:
https://gpdb.docs.pivotal.io/6-8/ref_guide/sql_commands/CREATE_EXTERNAL_TABLE.html
https://www.runoob.com/postgresql/postgresql-data-type.html
https://gp-docs-cn.github.io/docs/utility_guide/admin_utilities/gpfdist.html
一个多行文本的可能解决方案:
http://docs-cn.greenplum.org/v6/pxf/hdfs_text.html

posted on 2023-03-09 16:31  Caraxes  阅读(268)  评论(0)    收藏  举报