Re: Question Regarding COPY Command Handling of Line Breaks in PostgreSQL

From: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
To: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Question Regarding COPY Command Handling of Line Breaks in PostgreSQL
Date: 2025-07-11 13:07:32
Message-ID: CANzqJaB24YUU-toCxGWVUym2Fas2QATYhuZCM3M0ZHfkmcFMbw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jul 11, 2025 at 8:20 AM gzh <gzhcoder(at)126(dot)com> wrote:

> Dear,
>
> I am encountering an issue with the COPY command in PostgreSQL regarding
> the handling of line breaks in data fields. My PostgreSQL instance is
> installed on a Linux system.
>
> When I use the COPY command to export data to a CSV file and then import
> the same CSV file back into the database, all carriage return characters
> (CR) in the fields are automatically converted to line feed characters
> (LF). For example:
>
> Field content before import: *** (CR) ***
> Field content after import: *** (LF) ***
> I would like to know if there is a way to use the COPY command while
> preserving the original line breaks (CR) in the data fields during import.
>

What PG version?
What's the full command (including both shell and SQL commands)?

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dimitrios Apostolou 2025-07-11 14:46:19 Re: having temp_tablespaces on less reliable storage
Previous Message gzh 2025-07-11 12:20:38 Question Regarding COPY Command Handling of Line Breaks in PostgreSQL