471,354 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

using copy to load odd characters

Howdy:

Running PostgreSQL 7.3.3 on RedHat Linux 7.2

I'm trying to load data from a text file that
has an odd character in it (^@). From what I
could tell, it's a NULL character. How can I
load that into the database via the command line?

I've done the following:

[snip]

bcn2=> \copy db2_cn1pmemb from '/raid/backups/science/cn1pmemb.out' with
delimiter as '|' NULL as '\000'
\.
ERROR: copy: line 151676, Missing data for column "c_state"
lost synchronization with server, resetting connection
bcn2=> \copy db2_cn1pmemb from '/raid/backups/science/cn1pmemb.out' with
delimiter as '|' NULL as 'NULL'
\.
ERROR: copy: line 151676, Missing data for column "c_state"
lost synchronization with server, resetting connection
bcn2=> \copy db2_cn1pmemb from '/raid/backups/science/cn1pmemb.out' with
delimiter as '|' NULL as NULL
\.
ERROR: copy: line 151676, Missing data for column "c_state"
lost synchronization with server, resetting connection
bcn2=> \q
[/snip]

As well as '^@' and '\^@', but I haven't found anything that
works. Can someone tell me what I am doing wrong?

Thanks!

-X

Nov 12 '05 #1
1 1942
Johnson, Shaunn writes:
I'm trying to load data from a text file that
has an odd character in it (^@). From what I
could tell, it's a NULL character. How can I
load that into the database via the command line?


Depends on what data type the column is supposed to have. Character data
types cannot contain null bytes. The type bytea can store arbitrary
binary data. It requires you to escape null bytes so '\\000'.

--
Peter Eisentraut pe*****@gmx.net
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Ian | last post: by
4 posts views Thread by Gactimus | last post: by
3 posts views Thread by Random Person | last post: by
reply views Thread by mathlec | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.