How to implement the skip errors for copy from ?

Started by xbzhangalmost 12 years ago3 messagesgeneral
Jump to latest
#1xbzhang
xbzhang@kingbase.com.cn

I want to?implement the skip errors for copy from,lik as :create table A (c int primary key);copy A from stdin;112\.
copy will failed:ERROR: duplicate key violates primary key constraint "CC_PKEY"

CONTEXT: COPY CC, line 2: "1"
I want skip the error, and continue to copy the reset of tuple. The resultwill be that there are two rows in table A: 1 and 2.
how to?implement that ?

张晓博?? 研发二部
北京人大金仓信息技术股份有限公司
地址:北京市海淀区上地西路八号院上地科技大厦4号楼501
邮编:100085
电话:(010) 5885 1118 - 8450
手机:15311394463
邮箱:xbzhang@kingbase.com.cn

#2Vik Fearing
vik@postgresfriends.org
In reply to: xbzhang (#1)
Re: How to implement the skip errors for copy from ?

On 05/29/2014 09:25 AM, xbzhang wrote:

I want to implement the skip errors for copy from,lik as :
create table A (c int primary key);
copy A from stdin;
1
1
2
\.

copy will failed:
ERROR: duplicate key violates primary key constraint "CC_PKEY"
CONTEXT: COPY CC, line 2: "1"

I want skip the error, and continue to copy the reset of tuple. The result
will be that there are two rows in table A: 1 and 2.

how to implement that ?

Have a look at pgloader. http://pgloader.tapoueh.org/

--
Vik

#3Adrian Klaver
adrian.klaver@aklaver.com
In reply to: xbzhang (#1)
Re: How to implement the skip errors for copy from ?

On 05/29/2014 12:25 AM, xbzhang wrote:

I want to implement the skip errors for copy from,lik as :
create table A (c int primary key);
copy A from stdin;
1
1
2
\.

copy will failed:
ERROR: duplicate key violates primary key constraint "CC_PKEY"
CONTEXT: COPY CC, line 2: "1"

I want skip the error, and continue to copy the reset of tuple. The result
will be that there are two rows in table A: 1 and 2.

how to implement that ?

Use an external program like:

pgloader

http://pgloader.tapoueh.org/

or

pg_bulkload

http://pgbulkload.projects.pgfoundry.org/pg_bulkload.html

锟斤拷锟戒:xbzhang@kingbase.com.cn <mailto:xbzhang@kingbase.com.cn>

--
Adrian Klaver
adrian.klaver@aklaver.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general