PgAdmin 将文本列导出到 csv 文件

PgAdmin Exporting text column to csv file

我有一个包含 3 列的 table - 类型、名称和代码。 code 列包含 procedure/function 源代码。 我已使用 PgAdmin 4 v5 中的 Import/Export 选项将其导出到 csv 文件,但 code 列不会粘附到 csv 文件中的单个单元格。其中的数据分布在许多行和列中。 我已经检查 EncodingUTF8,它在导出其他 tables 时正常工作。

其他设置:Format: csvEncoding: UTF8。没有更改任何其他设置

有人可以帮助如何正确导出它。

对您所见内容的解释:

CREATE TABLE public.csv_test (
    fld_1 character varying,
    fld_2 character varying,
    fld_3 character varying,
    fld_4 character varying
);

insert into csv_test values ('1', E'line with line end. \n  New line', 'test', 'dog');
insert into csv_test values ('2', E'line with line end. \n  New line', 'test', 'dog');
insert into csv_test values ('3', E'line with line end. \n  New line \n Another line', 'test2', 'cat');
insert into csv_test values ('4', E'line with line end. \n  New line \n \t Another line', 'test3', 'cat');

select * from csv_test ;
 fld_1 |         fld_2         | fld_3 | fld_4 
-------+-----------------------+-------+-------
 1     | line with line end.  +| test  | dog
       |   New line            |       | 
 2     | line with line end.  +| test  | dog
       |   New line            |       | 
 3     | line with line end.  +| test2 | cat
       |   New line           +|       | 
       |  Another line         |       | 
 4     | line with line end.  +| test3 | cat
       |   New line           +|       | 
       |          Another line |       | 

\copy csv_test to csv_test.csv with (format 'csv');
\copy csv_test to csv_test.txt;

--fld_2 has line ends and/or tabs so in CSV the data will wrap inside the quotes.
cat csv_test.csv 
1,"line with line end. 
  New line",test,dog
2,"line with line end. 
  New line",test,dog
3,"line with line end. 
  New line 
 Another line",test2,cat
4,"line with line end. 
  New line 
         Another line",test3,cat

-- In text format the line ends and tabs are shown and not wrapped.
cat csv_test.txt 
1       line with line end. \n  New line        test    dog
2       line with line end. \n  New line        test    dog
3       line with line end. \n  New line \n Another line        test2   cat
4       line with line end. \n  New line \n \t Another line     test3   cat