Skip to content

Add FORCE_QUOTE option to Import/Export Data in v9.x #8583

Closed
@aquarius777

Description

@aquarius777

I’d like the “Import/Export Data” tool in pgAdmin 4 (v9.1) to include a “Force Quote All Columns” checkbox in the Options tab. This would add the FORCE_QUOTE option to the underlying COPY command, ensuring all CSV values—header and data—are quoted with the specified quote character (e.g., ").

For example, with my table "simple" (columns a, b, c as VARCHAR), I export using Delimiter ; and Quote ", excluding column c. I currently get:

a;b
1;4
2;5
3;6
one;two

But I'd like to get:

"a";"b"
"1";"4"
"2";"5"
"3";"6"
"one";"two"

This would make exports consistent and easier to use in tools expecting fully quoted CSVs, without needing to switch to psql.

I’ve tried a few workarounds:

Using psql with \copy: This works perfectly with a command like:
sql
\copy (SELECT 'a' AS "a", 'b' AS "b" UNION ALL SELECT a, b FROM simple) TO 'C:\path\to\file.csv' WITH (FORMAT CSV, DELIMITER ';', QUOTE '"', FORCE_QUOTE ("a", "b"))

It gives me the quoted output I want, but it’s a hassle to leave pgAdmin, open psql, and write a custom query—especially for quick exports.

Thanks a lot!

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions