Question Regarding COPY Command Handling of Line Breaks in PostgreSQL

From: gzh <gzhcoder(at)126(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Question Regarding COPY Command Handling of Line Breaks in PostgreSQL
Date: 2025-07-11 12:20:38
Message-ID: 43b9fb8c.8b5c.197f96e3544.Coremail.gzhcoder@126.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

Thank you for your assistance.

Best regards,
gzh

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2025-07-11 13:07:32 Re: Question Regarding COPY Command Handling of Line Breaks in PostgreSQL
Previous Message Dominique Devienne 2025-07-11 12:11:44 Re: Aggregate versions of hashing functions (md5, sha1, etc...)