When using the \copy command with psql I have a file with empty values. These values are not to be null but instead always an empty string.

My command:

\copy agltransact FROM 'dbo_agltransact.csv' with null as '' CSV HEADER;

The error I get:

ERROR:  null value in column "apar_id" violates not-null constraint

I have this data:


I want the next to last columns to be an empty string.


Figured it out. I need to escape and output the single quotes

\copy agltransact FROM 'dbo_agltransact.csv' with null as E'\'\'' CSV HEADER;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.