I'm trying to migrate some data from postgres to mysql. for that i'm doing a simple sql in postgres and load it to mysql. since format is a bit different the flag -AF $'\t' in psql makes it tab delimiter which is great.

The missing part is that psql return null as empty string. where in mysql it represent as \N. Is there a flag that manage it? I would really like to avoid putting ifnull around each column in the select.

  • Are you building your own SQL statements to export a table as a complete INSERT?
    – matigo
    May 9, 2021 at 21:18
  • something like that. I read an input and load it directly to the mysql target. NULLs are treated as empty strings for now and i'm looking to fix that.
    – Nir
    May 10, 2021 at 7:14

1 Answer 1


psql has a flag that controls the way null is outputted -P 'null=\N'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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