错误:COPY分隔符必须是一个单字节字符 [英] ERROR: COPY delimiter must be a single one-byte character

查看:1987
本文介绍了错误:COPY分隔符必须是一个单字节字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将数据从带有分隔符〜,〜的平面文件加载到PostgreSQL表中。我尝试了如下操作,但看起来分隔符有限制。如果COPY语句不允许使用多个字符作为分隔符,

I want to load the data from a flat file with delimiter "~,~" into a PostgreSQL table. I have tried it as below but looks like there is a restriction for the delimiter. If COPY statement doesn't allow multiple chars for delimiter, is there any alternative to do this?

metadb=# \COPY public.CME_DATA_STAGE_TRANS FROM 'E:\Infor\Outbound_Marketing\7.2.1\EM\metadata\pgtrans.log' WITH      DELIMITER AS '~,~'
ERROR:  COPY delimiter must be a single one-byte character
\copy: ERROR:  COPY delimiter must be a single one-byte character


推荐答案

如果您使用的是 Vertica ,您可以使用E'\t'或U&'\0009'

If you are using Vertica, you could use E'\t'or U&'\0009'


要指示非打印定界符(例如制表符),
以扩展字符串语法(E'...')指定字符。如果您的
数据库启用了StandardConformingStrings,请使用Unicode字符串
文字(U& ...)。例如,在
中使用E’ampt或U&’000000来指定制表符作为分隔符。

To indicate a non-printing delimiter character (such as a tab), specify the character in extended string syntax (E'...'). If your database has StandardConformingStrings enabled, use a Unicode string literal (U&'...'). For example, use either E'\t' or U&'\0009' to specify tab as the delimiter.

这篇关于错误:COPY分隔符必须是一个单字节字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆