0

My text file look like:

\home\stanley:123456789
c:/kobe:213
\tej\home\ant:222312

and create FOREIGN TABLE Steps:

CREATE FOREIGN TABLE file_check(txt text) SERVER file_server OPTIONS (format 'text', filename '/home/stanley/check.txt');

after select file_check (using: select * from file_check)

my console show me

homestanley:123456789
c:/kobe:213
ejhomeant:222312

Anyone can help me??

1
  • 1
    What is your setting for standard_conforming_strings (and which Postgres version are you using?) Commented Apr 12, 2013 at 8:39

1 Answer 1

1

The file foreign-data-wrapper uses the same rules as COPY (presumably because it's the same code underneath). You've got to consider that backslash is an escape character...

http://www.postgresql.org/docs/9.2/static/sql-copy.html

Any other backslashed character that is not mentioned in the above table will be taken to represent itself. However, beware of adding backslashes unnecessarily, since that might accidentally produce a string matching the end-of-data marker (.) or the null string (\N by default). These strings will be recognized before any other backslash processing is done.

So you'll either need to double-up the backslashes or perhaps try it as a single-column csv file and see if that helps

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.