Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aquarius777 opened this issue Mar 21, 2025 · 0 comments
Open

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

aquarius777 opened this issue Mar 21, 2025 · 0 comments

Comments

@aquarius777
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants