How can I remove the Null representation from PostgreSQL table when exporting to a text delimited file using pgAdmin4?

117 views Asked by At

Im using Postgresql with pgadmin4 for exporting a table to a text-delimited file. I'm using 'Import/Export Data' and I need to change the default Null representation (\N) by an empty value. But I can not find how.

I've tried ESCAPE key '''' but nothing seems to work. I need to keep it simple so I not using \copy.

id name age
1  john 20
2  mary 
3       34

When exporting to a text-delimited file I get this results

1~john~20
2~mary~\N
3~\N~34

I want to remove the null representation from the output results expected

1~john~20
2~mary~
3~~34
1

There are 1 answers

1
jjanes On

You can't do that with pgAdmin4 by the import/export, as it interprets the empty string as meaning that the NULL setting is omitted altogether, meaning it remains as its default of \N. There is no problem with setting it to the empty string when using psql directly. You could argue that this is a bug in pgAdmin4.

You might be able to get what you want by changing from the "text" format to the "csv" format, but that might cause other aspect to be messed up.

I need to keep it simple so I not using \copy

I like to keep to simple as well, which is why I generally do use \copy and generally do not use pgAdmin4.